-
Notifications
You must be signed in to change notification settings - Fork 706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it flexible to load macros in SSG #12816
base: master
Are you sure you want to change the base?
Make it flexible to load macros in SSG #12816
Conversation
The project defines the JINJA_MACROS_DIRECTORY contant based on the assumption that SSG library is only executed internally. Once the library was exported and is expected to be used externally, this flexibility is necessary. It was created another function that allows the content directory to be informed. Signed-off-by: Marcus Burghardt <[email protected]>
Skipping CI for Draft Pull Request. |
This function was created to use the flexibility provided by load_macros_from_content_dir in jinja.py. Signed-off-by: Marcus Burghardt <[email protected]>
Allow to expand macros used in variables when the variable functions are called outside the project. Signed-off-by: Marcus Burghardt <[email protected]>
a80a889
to
2567a19
Compare
While I'm all in favor of adding type hints, the style guide still states all build system code needs to be Python 2 compatible. Last I checked the only hold up was OL7. I have asked in #12046 to get more details on this. |
Where the type hints were included they are also compatible with Python 2. |
But for Python 2 the type hints would have to be in comments, right? |
It is a recommendation, but not mandatory. According to the notes on this link, if moved to type comment, type annotation could not be used together. So would prefer to remove both than keep as type comment considering the intention to drop Python2 support as soon as we can. We also have type hints in other files, so is it worth to remove it on this PR? Let me know what do you think so I can quickly update the PR if necessary. Thanks |
Signed-off-by: Marcus Burghardt <[email protected]>
But the code won't work with Python 2 if you keep the type hints. The type hint syntax is a new thing in Python 3.5 and wasn't present in Python 2. If you want to have the code compatible with Python 2, you have to put the type hints to comments.
|
Ok. Let me quickly remove in this specific PR so we can move forward. I will comment in the discussion to confirm if we are already good to officially remove Python 2 support. The informed date there was 2014/12. |
yeah, it would be great to drop the python2 support soon, the type hints feature is a nice reason |
Signed-off-by: Marcus Burghardt <[email protected]>
0e2e96f
to
371915d
Compare
Type hints removed from functions changed in this PR @jan-cerny . |
Code Climate has analyzed commit 371915d and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 61.9% (0.1% change). View more on Code Climate. |
Description:
The CaC/content project uses Jinja2 macros during building time in order to make the content more flexible or easier to be managed in a context with several products. Macros are used in multiple files and should be properly processed in order to return the expected data.
Until recently the SSG library was not expected to be used externally and therefore the path to load macros was hard-coded. This PR brings more flexibility to process yaml files with macros by allowing the macros to be load also from an informed directory.
Rationale:
Allow Jinja2 macros to be consumed when SSG library is called outside the project.
Review Hints:
Here is an example to simulate the issue in a virtual environment:
Now you can use the example script from #12797 and you will notice many exceptions similar to what was reported in #12797 (comment).
Once the issue is reproduced, you can try again with the fixes:
No issues are expected now.
Unit tests can be trying with: