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

Add stubs for pluggy==1.2.0 #10473

Merged
merged 15 commits into from
Jul 20, 2023
Merged

Conversation

hoefling
Copy link
Contributor

This PR suggests to add stubs for the pluggy package of the current version 1.2.0. The reason for this is that although pluggy itself is (almost) completely typed, the package ships no PEP 561 marker yet, as there is no consensus about what types to expose, see pytest-dev/pluggy#414.

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
@github-actions

This comment has been minimized.

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
stubs/pluggy/pluggy/_hooks.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_result.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_tracing.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_manager.pyi Outdated Show resolved Hide resolved
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@github-actions

This comment has been minimized.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks pretty good; a few remarks below.

Seems a bit unfortunate to add these stubs given how heavily typed the runtime package is, but if they don't want to add a py.typed file, I guess I'm okay with adding these.

stubs/pluggy/pluggy/_hooks.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_hooks.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_hooks.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_hooks.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_hooks.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_hooks.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_manager.pyi Show resolved Hide resolved
stubs/pluggy/pluggy/_result.pyi Outdated Show resolved Hide resolved
stubs/pluggy/@tests/stubtest_allowlist.txt Outdated Show resolved Hide resolved
Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>
Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>
@github-actions

This comment has been minimized.

@hoefling
Copy link
Contributor Author

@AlexWaygood

Seems a bit unfortunate to add these stubs given how heavily typed the runtime package is, but if they don't want to add a py.typed file, I guess I'm okay with adding these.

TBH I was expecting the package to expose type hints in 1.2.0, but since it is postponed, I'd rather have a types-pluggy for a year or so out there to not to carry around my own stubs along in every pytest plugin repo. Once the type hints are exposed, I think I'll be the first one to drop the stubs again and carry one less types-* dependency around.

Another (not so obvious and rather a personal) benefit from this PR is that thanks to you, I'm getting a great sync on the latest typeshed development progress ;-)

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly there, I think!

stubs/pluggy/pluggy/_tracing.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_result.pyi Outdated Show resolved Hide resolved
stubs/pluggy/pluggy/_manager.pyi Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

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

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/config/__init__.py:471: error: Incompatible types in assignment (expression has type "dict[str, bool]", variable has type "_HookSpecOpts | None")  [assignment]
+ src/_pytest/config/__init__.py:734: error: "PytestPluginManager" has no attribute "_name2plugin"  [attr-defined]
+ src/_pytest/config/__init__.py:735: error: "PytestPluginManager" has no attribute "_name2plugin"  [attr-defined]
+ src/_pytest/config/__init__.py:737: error: "PytestPluginManager" has no attribute "_name2plugin"  [attr-defined]
+ src/_pytest/config/__init__.py:738: error: "PytestPluginManager" has no attribute "_name2plugin"  [attr-defined]
+ src/_pytest/config/__init__.py:1069: error: Incompatible types in assignment (expression has type "Any | None", variable has type "TerminalReporter")  [assignment]
+ src/_pytest/pytester.py:754: error: "PytestPluginManager" has no attribute "reprec"  [attr-defined]
+ src/_pytest/logging.py:666: error: Argument 1 to "_LiveLoggingStreamHandler" has incompatible type "Any | None"; expected "TerminalReporter"  [arg-type]
+ src/_pytest/helpconfig.py:165: error: Item "None" of "Any | None" has no attribute "_tw"  [union-attr]
+ src/_pytest/helpconfig.py:230: error: Item "None" of "Any | None" has no attribute "stats"  [union-attr]
+ testing/test_pluginmanager.py:245: error: Item "None" of "Any | None" has no attribute "__name__"  [union-attr]
+ testing/test_pluginmanager.py:246: error: Item "None" of "Any | None" has no attribute "__name__"  [union-attr]
+ testing/test_pluginmanager.py:339: error: Item "None" of "Any | None" has no attribute "__name__"  [union-attr]
+ testing/test_pluginmanager.py:354: error: Item "None" of "Any | None" has no attribute "x"  [union-attr]

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@AlexWaygood AlexWaygood merged commit 4f56889 into python:main Jul 20, 2023
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants