typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

`pkg_resources` (setuptools): Make stubtest-complete and pyright-strict

Open Avasam opened this issue 1 year ago • 4 comments

The first commit only reorder names to be closer to implementation. Making it easier to compare with the original code, and reducing changes in the following commit. Whilst still avoiding forward referenced.

So why even complete pkg_resources in the first place, if it's considered deprecated in favor of importlib.resources, importlib.metadata and their backports? Because I've started merging the stubs directly into the setuptools repo, with the goal of being able to take it out of typeshed. And in doing so, found a lot of improvements to the typeshed stubs. At that point I was a few changes away from completing it, so here it is.

This also allowed me to cross-validate a handful of annotations, and I'll use the typeshed stubs as the reference for an upcoming PR that finishes typing pkg_resources upstream.

Avasam avatar Feb 20 '24 00:02 Avasam

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 20 '24 01:02 github-actions[bot]

Diff from mypy_primer, showing the effect of this PR on open source code:

bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch/storage.py: note: In function "load_storage_plugins":
+ src/bandersnatch/storage.py:371: error: Module not callable  [operator]
+ src/bandersnatch/filter.py: note: In member "_load_filters" of class "LoadedFilters":
+ src/bandersnatch/filter.py:192: error: Module not callable  [operator]

isort (https://github.com/pycqa/isort)
+ isort/settings.py:367: error: Argument 2 to "setdefault" of "MutableMapping" has incompatible type Module; expected "Dict[str, Any]"  [arg-type]
+ isort/settings.py:725: error: Incompatible types in assignment (expression has type Module, variable has type "Optional[Callable[..., List[str]]]")  [assignment]
+ isort/settings.py:730: error: Incompatible return value type (got "Union[Callable[[Iterable[str], Optional[Callable[[str], Any]], bool], List[str]], overloaded function, None]", expected "Callable[..., List[str]]")  [return-value]

alerta (https://github.com/alerta/alerta)
- alerta/utils/plugin.py:49: error: Unused "type: ignore" comment  [unused-ignore]
+ alerta/utils/webhook.py:31: error: Module not callable  [operator]
+ alerta/utils/plugin.py:42: error: Module not callable  [operator]

github-actions[bot] avatar Feb 20 '24 07:02 github-actions[bot]

Diff from mypy_primer, showing the effect of this PR on open source code:

bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch/storage.py: note: In function "load_storage_plugins":
+ src/bandersnatch/storage.py:371: error: Module not callable  [operator]
+ src/bandersnatch/filter.py: note: In member "_load_filters" of class "LoadedFilters":
+ src/bandersnatch/filter.py:192: error: Module not callable  [operator]

isort (https://github.com/pycqa/isort)
+ isort/settings.py:367: error: Argument 2 to "setdefault" of "MutableMapping" has incompatible type Module; expected "Dict[str, Any]"  [arg-type]
+ isort/settings.py:725: error: Incompatible types in assignment (expression has type Module, variable has type "Optional[Callable[..., List[str]]]")  [assignment]
+ isort/settings.py:730: error: Incompatible return value type (got "Union[Callable[[Iterable[str], Optional[Callable[[str], Any]], bool], List[str]], overloaded function, None]", expected "Callable[..., List[str]]")  [return-value]

alerta (https://github.com/alerta/alerta)
- alerta/utils/plugin.py:49: error: Unused "type: ignore" comment  [unused-ignore]
+ alerta/utils/webhook.py:31: error: Module not callable  [operator]
+ alerta/utils/plugin.py:42: error: Module not callable  [operator]

github-actions[bot] avatar Feb 20 '24 08:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 21 '24 01:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 28 '24 01:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 28 '24 01:02 github-actions[bot]

Self-reviewing the amount of changes in 1 file, I'll put this back as draft and split it up in smaller chunks.

Avasam avatar Feb 28 '24 05:02 Avasam

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 29 '24 19:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 29 '24 21:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 29 '24 21:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 29 '24 22:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Mar 02 '24 20:03 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Mar 04 '24 01:03 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Mar 05 '24 23:03 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Mar 06 '24 20:03 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Mar 08 '24 03:03 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Mar 08 '24 04:03 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Mar 08 '24 04:03 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Mar 08 '24 05:03 github-actions[bot]