Skip to content

Commit

Permalink
Merge pull request #434 from bluetech/typing4
Browse files Browse the repository at this point in the history
Export pluggy's typing
  • Loading branch information
bluetech authored Aug 26, 2023
2 parents 1b1042e + 62da97c commit c53af98
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
18 changes: 18 additions & 0 deletions changelog/428.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Pluggy now exposes its typings to static type checkers.

As part of this, the following changes are made:

- Renamed ``_Result`` to ``Result``, and exported as :class:`pluggy.Result`.
- Renamed ``_HookRelay`` to ``HookRelay``, and exported as :class:`pluggy.HookRelay`.
- Renamed ``_HookCaller`` to ``HookCaller``, and exported as :class:`pluggy.HookCaller`.
- Exported ``HookImpl`` as :class:`pluggy.HookImpl`.
- Renamed ``_HookImplOpts`` to ``HookimplOpts``, and exported as :class:`pluggy.HookimplOpts`.
- Renamed ``_HookSpecOpts`` to ``HookspecOpts``, and exported as :class:`pluggy.HookspecOpts`.
- Some fields and classes are marked ``Final`` and ``@final``.
- The :ref:`api-reference` is updated to clearly delineate pluggy's public API.

Compatibility aliases are put in place for the renamed types.
We do not plan to remove the aliases, but we strongly recommend to only import from ``pluggy.*`` to ensure future compatibility.

Please note that pluggy is currently unable to provide strong typing for hook calls, e.g. ``pm.hook.my_hook(...)``,
nor to statically check that a hook implementation matches the hook specification's type.
2 changes: 2 additions & 0 deletions docs/api_reference.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
:orphan:

.. _`api-reference`:

API Reference
=============

Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ dev =
testing =
pytest
pytest-benchmark
[options.package_data]
pluggy = py.typed

[devpi:upload]
formats=sdist.tgz,bdist_wheel
1 change: 1 addition & 0 deletions src/pluggy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
__version__ = "unknown"

__all__ = [
"__version__",
"PluginManager",
"PluginValidationError",
"HookCaller",
Expand Down
4 changes: 2 additions & 2 deletions src/pluggy/_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from typing import Tuple


_Writer = Callable[[str], None]
_Processor = Callable[[Tuple[str, ...], Tuple[Any, ...]], None]
_Writer = Callable[[str], object]
_Processor = Callable[[Tuple[str, ...], Tuple[Any, ...]], object]


class TagTracer:
Expand Down
Empty file added src/pluggy/py.typed
Empty file.

0 comments on commit c53af98

Please sign in to comment.