Skip to content
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

Update the Jinja2Templates() constructor to allow PathLike #1292

Merged
merged 6 commits into from Sep 26, 2021

Conversation

tonybaloney
Copy link
Contributor

The directory argument for Jinja2Templates is annotated as a str, which means a type checker fails if you pass a pathlib.Path, but Jinja2 accepts PathLike[str] (either a path string or a Path) for environment creation.

This PR updates the type annotation to allow both cases.

Copy link
Sponsor Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonybaloney Thanks for the PR! 🎉

I also prefer to import each type from typing, but I would like to maintain consistency between modules. 😗

Would you mind checking my suggestions? It also solves the CI.

starlette/templating.py Outdated Show resolved Hide resolved
starlette/templating.py Outdated Show resolved Hide resolved
starlette/templating.py Outdated Show resolved Hide resolved
tonybaloney and others added 3 commits September 27, 2021 07:28
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
@tonybaloney
Copy link
Contributor Author

Done! Thanks

starlette/templating.py Outdated Show resolved Hide resolved
Copy link
Sponsor Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tonybaloney ! 🥳

@Kludex Kludex merged commit 6c556f6 into encode:master Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants