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

static_folder shows str type, not pathlib.Path #4150

Closed
gitpushdashf opened this issue Jun 15, 2021 · 0 comments · Fixed by #4152
Closed

static_folder shows str type, not pathlib.Path #4150

gitpushdashf opened this issue Jun 15, 2021 · 0 comments · Fixed by #4152
Labels
Milestone

Comments

@gitpushdashf
Copy link

Using Python 3.9, mypy will complain about static_folder being Optional[str] and not accepting a pathlib.Path.

note: Revealed type is "pathlib.Path*" # This is what I'm feeding it
Revealed type is "Union[builtins.str, None]" # this is reveal_path() for app.static_folder
error: Incompatible types in assignment (expression has type "Path", variable has type "Optional[str]")
Found 1 error in 1 file (checked 1 source file)

Not sure why Python 3.8 doesn't do this.

I think maybe here: https://github.com/pallets/flask/blob/main/src/flask/scaffold.py#L80

I think this needs to be _static_folder: t.Union[t.Optional[str], Path] = None

Or maybe... _static_folder: t.Optional[t.Union[str, Path]] = None

And at the top: from pathlib import Path

Thank you!

@greyli greyli added the typing label Jun 18, 2021
@greyli greyli added this to the 2.0.2 milestone Jun 18, 2021
@davidism davidism linked a pull request Aug 6, 2021 that will close this issue
3 tasks
@davidism davidism changed the title flask 2.0.1 with Python 3.9 shows static_folder as str type, not pathlib.Path static_folder shows str type, not pathlib.Path Aug 6, 2021
@davidism davidism closed this as completed Aug 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants