pip_api: type hints by woodruffw · Pull Request #97 · di/pip-api · GitHub
source link: https://github.com/di/pip-api/pull/97
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Turns out that this is a significant pain due to the vendored modules:
$ mypy pip_api
pip_api/_vendor/pyparsing.py:123: error: Module "itertools" has no attribute "ifilterfalse"; maybe "filterfalse"?
pip_api/_vendor/pyparsing.py:123: error: Name "filterfalse" already defined (possibly by an import)
pip_api/_vendor/pyparsing.py:126: error: Module "_thread" has no attribute "RLock"
pip_api/_vendor/pyparsing.py:143: error: Cannot find implementation or library stub for module named "ordereddict"
pip_api/_vendor/pyparsing.py:143: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
pip_api/_vendor/pyparsing.py:143: error: Name "_OrderedDict" already defined (possibly by an import)
pip_api/_vendor/pyparsing.py:145: error: Cannot assign to a type
pip_api/_vendor/pyparsing.py:145: error: Incompatible types in assignment (expression has type "None", variable has type "Type[OrderedDict[Any, Any]]")
pip_api/_vendor/pyparsing.py:150: error: Name "SimpleNamespace" already defined (possibly by an import)
pip_api/_vendor/pyparsing.py:233: error: Module has no attribute "maxint"
pip_api/_vendor/pyparsing.py:234: error: Name "xrange" is not defined
pip_api/_vendor/pyparsing.py:236: error: Name "_ustr" already defined on line 227
pip_api/_vendor/pyparsing.py:260: error: Cannot find implementation or library stub for module named "__builtin__"
pip_api/_vendor/pyparsing.py:1800: error: Name "_FifoCache" already defined on line 1771
pip_api/_vendor/pyparsing.py:1829: error: Need type annotation for "packrat_cache" (hint: "packrat_cache: Dict[<type>, <type>] = ...")
pip_api/_vendor/pyparsing.py:2902: error: "Type[ParserElement]" has no attribute "_literalStringClass"
pip_api/_vendor/pyparsing.py:5086: error: Not all arguments converted during string formatting
pip_api/_vendor/pyparsing.py:5944: error: "Callable[[VarArg(Any), KwArg(Any)], Any]" has no attribute "ANY_VALUE"
pip_api/_vendor/pyparsing.py:6730: error: Need type annotation for "_ranges" (hint: "_ranges: List[<type>] = ...")
pip_api/_vendor/pyparsing.py:6799: error: Need type annotation for "_ranges" (hint: "_ranges: List[<type>] = ...")
Found 19 errors in 1 file (checked 21 source files)
The CI will pass above, but the parent call to mypy
in pip-audit
will continue to fail because of these inner errors. I've tried to mark the imports for pyparsing
with # type: ignore
, but that doesn't seem to have done anything...
Edit: I've added mypy
to the CI to (hopefully) demonstrate the failure.
Recommend
-
5
New issue README: fix a small formatting typo #91
-
7
Copy link Contributor woodruffw
-
7
New issue dwarf: initial DWARFv5 support #363
-
9
Copy link Contributor Author woodru...
-
7
New issue Support LLVM_LINK_FLAGS #51
-
5
New issue api-reference/json: document vulnerabilities in responses #10431
-
3
Copy link Contributor woodruffw
-
6
Copy link Contributor woodruffw
-
5
Copy link Contributor woodruffw
-
9
Copy link Contributor woodruffw
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK