Skip to content

Allow pathlib.Path for template_folder #4921

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

Merged
merged 1 commit into from
Dec 24, 2022

Conversation

ivanovmg
Copy link
Contributor

@ivanovmg ivanovmg commented Dec 22, 2022

This PR allows template_folder argument to be a pathlib.Path object.

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

I added a new test, which ensures that template_folder can be pathlib.Path object.
However, when I added this tests, it was already successful.
I noticed that there are no similar tests of this kind in regards to template_folder.

I suppose that the issue referenced is related to typing only, because according to the successful test, one can use this out of the box, and there is no need to convert it into a str object.

app = Flask(
    __name__,
    template_folder=pathlib.Path("templates"),
)

@davidism davidism force-pushed the fix/template_folder branch from 8cf929a to 09112cf Compare December 24, 2022 18:17
@davidism davidism added this to the 2.2.3 milestone Dec 24, 2022
@davidism davidism merged commit 631b6dd into pallets:2.2.x Dec 24, 2022
@legoktm
Copy link

legoktm commented Dec 24, 2022

Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants