Import the pathlib module in main.py instead of the individual Path class
#1962
Unanswered
gioannidis
asked this question in
Questions
Replies: 1 comment 1 reply
|
Why? typer/main.py already imports Path from pathlib. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
First Check
Example Code
Description
This discussion follows up to #1954 and is opened per the contribution guidelines. It is addressed to the development/contributing team, proposing a pull request.
Goal: run
pytestwith both real filesystems andpyfakefsfor in-memory implementation. This uses stringified annotations with__future__.annotations, as discussed in #1954, to force eager annotation evaluation.Problem: an exception is raised from
get_click_type, namely:Root cause: an upstream bug in
pyfakefs, which has been already reported in issue #1334. This is not expected to be fixed in the short-term due to the scale of involved refactoring.Proposed fix: refactor
typer/main.pyto import thepathlibmodule itself, instead of directly importingPath. More concretely:... and also update the call sites:
Path->pathlib.Path.The proposed fix in module_import.patch.
Test cases: all tests pass. Windows tests have been skipped.
Key takeaways:
from pathlib import Path->import pathlibpyfakefsissue #1334Operating System
Linux
Operating System Details
Project Version
0.27.2
Python Version
3.14.6
Additional Context
No response
All reactions