mirror of
https://github.com/ansible/ansible.git
synced 2026-02-03 20:40:24 -05:00
🧪 Replace distlib type ignores with stubs
The stubs are taken from the unmerged PR [[1]] upstream. MyPy is set up to rely on them instead of the missing package type annotations. [1]: https://github.com/pypa/distlib/pull/195
This commit is contained in:
parent
e05b6e7475
commit
7328efbdf3
5 changed files with 18 additions and 3 deletions
|
|
@ -5,6 +5,6 @@ include licenses/*.txt
|
|||
include requirements.txt
|
||||
recursive-include packaging *.py *.j2
|
||||
recursive-include test/integration *
|
||||
recursive-include test/sanity *.in *.json *.py *.txt *.ini
|
||||
recursive-include test/sanity *.in *.json *.py *.pyi *.txt *.ini
|
||||
recursive-include test/support *.py *.ps1 *.psm1 *.cs *.md
|
||||
recursive-include test/units *
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ else:
|
|||
HAS_PACKAGING = True
|
||||
|
||||
try:
|
||||
from distlib.manifest import Manifest # type: ignore[import]
|
||||
from distlib import DistlibException # type: ignore[import]
|
||||
from distlib.manifest import Manifest
|
||||
from distlib import DistlibException
|
||||
except ImportError:
|
||||
HAS_DISTLIB = False
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
# NOTE: `distlib` is untyped as of 10 Oct 2025.
|
||||
# NOTE: This should be removed once types are upstream.
|
||||
# Ref: https://github.com/pypa/distlib/pull/195
|
||||
|
||||
class DistlibException(Exception): ...
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# NOTE: `distlib` is untyped as of 10 Oct 2025.
|
||||
# NOTE: This should be removed once types are upstream.
|
||||
# Ref: https://github.com/pypa/distlib/pull/195
|
||||
|
||||
class Manifest:
|
||||
def __init__(self, base: str | None = ...) -> None: ...
|
||||
def process_directive(self, directive: str) -> None: ...
|
||||
def sorted(self, wantdirs: bool = ...) -> list[str]: ...
|
||||
|
|
@ -13,6 +13,8 @@ strict_optional = False
|
|||
# See: https://github.com/python/mypy/issues/4717
|
||||
disable_error_code = attr-defined,safe-super,type-abstract
|
||||
|
||||
mypy_path = ${MYPY_CONFIG_FILE_DIR}/_type_stubs
|
||||
|
||||
# Some controller unit tests use ansible_collections imports, both real and test-specific.
|
||||
# The real imports are not currently visible to mypy.
|
||||
# There's little point in exposing the test-specific imports.
|
||||
|
|
|
|||
Loading…
Reference in a new issue