Include os.PathLike when typing path parameters - #940
Conversation
|
Should we update the |
|
@knutnergaard you are the typing guru here, thoughts? |
|
On vacation, so can't check, but the pathlib.Path annotation in normalizeFilePath is likely too strict, and should be changed to os.pathLike. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #940 +/- ##
=======================================
Coverage 86.69% 86.69%
=======================================
Files 43 43
Lines 6727 6728 +1
Branches 972 972
=======================================
+ Hits 5832 5833 +1
Misses 694 694
Partials 201 201
🚀 New features to boost your workflow:
|
|
Strange type checking error here, fontParts/Lib/fontParts/base/font.py Lines 466 to 467 in 76a6673 |
|
@adbac As far as I can tell, yes, but clearly mypy disagrees... |
I think it might return a tuple of bytes as well, depending on the input type. Converting path to string should do it. |
|
Hey @adbac This is not just a ruff formatting check, I'll run that and review! |
* Fix release (#936) * Update Readme * Update .gitignore * Rework publishing * fixup * Fix release (#937) * Update Readme * Update .gitignore * Rework publishing * fixup * Control how version number is constructed * Control how version number is constructed * Update pyproject.toml * Fix * Fixup * Update NEWS * Dropping test.pypi.org. Version number will be hell to sort * Include `os.PathLike` when typing path parameters (#940) * update type hints for paths to use os.PathLike * update path type hints in generate methods * make RFont._save path type hint compatible with superclass * widen type parameter type in normalizeFilePath function * call os.fsdecode on path to get a string object * Ruff formatting run (#941) * Update News for release --------- Co-authored-by: Adrien Bachelart <126618591+adbac@users.noreply.github.com>
|
Thanks! |
In order to pass
pathlib.Pathobjects to the__init__andsavemethods of font objects, this PR addsos.PathLiketo the type hints of path parameters.Currently, only
RFont._inittypespathOrObjectthis way, which means it isn't picked up by static type checkers when initializing objects.