-
-
Notifications
You must be signed in to change notification settings - Fork 968
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
Add missing type hints to Jinja2Templates() #2157
Conversation
FileSystemLoader() from jinja2 supports a single or sequence of str or PathLike
Can you add a test that proves it, please? |
Currently the patch changes no logic at all and appears thoroughly tested by existing starlette tests. Additionally, mypy verifies the types hints thoroughly from starlette's API through to Jinja2's. Jinja2 has type hints and tests for sequences already which mypy propagates through starlette. On that basis, what extra tests are needed? Thanks! |
We are interested in making sure that |
Thanks for the info, please find both a test and a very minor add to the docs. I attempted to copy the existing styles, variable names as closely as I could. Happy to take any and all feedback. If you are happy with it, and want me to squash it before committing please let me know. |
No squashs are needed from your behalf. Thanks. 🙏 |
It's a bit troublesome when you create PRs from the fork's main branch. I can't push code to this branch. Can you apply these changes, please: a46a825 ? |
I'm sorry, when I read the development docs I don't remember seeing any guidance. |
I just need the changes on that commit to be here.
Hmm... It's fine the way you did, it's really just the branch, because it's protected, so I can't push there. |
Nice refactor, it is much clearer than my patch. As Jinja can read files from subdir's of template directories I was being overly cautious in asserting that one directory was not the child or the same as the other. I shortened the html templates so black does not split them into 3 lines due to their line length, and the template text does not have to say Hello :). I also found that |
Thanks @mattaw 🙏 |
Summary
FileSystemLoader()
from jinja2 (see its comment block) has supported both a singlestr
/PathLike
or asequence of them for at least four years. Starlette currently only has typehints for a single
str
/PathLike
.Mypy passes. Documented and test created.
Checklist