Skip to content

Commit ae22ac2

Browse files
committed
Config changes to use our custom stubs
1 parent 89b4401 commit ae22ac2

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

mypy.ini

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ disable_error_code =
1818

1919
## local
2020

21+
# Use our custom stubs for distutils
22+
mypy_path = $MYPY_CONFIG_FILE_DIR/typings
23+
2124
# CI should test for all versions, local development gets hints for oldest supported
2225
# But our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually.
2326
# python_version = 3.8
@@ -46,20 +49,16 @@ disable_error_code = attr-defined
4649
[mypy-pkg_resources.tests.*]
4750
disable_error_code = import-not-found
4851

49-
# - distutils doesn't exist on Python 3.12, unfortunately, this means typing
50-
# will be missing for subclasses of distutils on Python 3.12 until either:
51-
# - support for `SETUPTOOLS_USE_DISTUTILS=stdlib` is dropped (#3625)
52-
# for setuptools to import `_distutils` directly
53-
# - or non-stdlib distutils typings are exposed
5452
# - The following are not marked as py.typed:
53+
# - jaraco: Since mypy 1.12, the root name of the untyped namespace package gets called-out too
5554
# - jaraco.develop: https://github.com/jaraco/jaraco.develop/issues/22
5655
# - jaraco.envs: https://github.com/jaraco/jaraco.envs/issues/7
5756
# - jaraco.packaging: https://github.com/jaraco/jaraco.packaging/issues/20
5857
# - jaraco.path: https://github.com/jaraco/jaraco.path/issues/2
5958
# - jaraco.test: https://github.com/jaraco/jaraco.test/issues/7
6059
# - jaraco.text: https://github.com/jaraco/jaraco.text/issues/17
6160
# - wheel: does not intend on exposing a programmatic API https://github.com/pypa/wheel/pull/610#issuecomment-2081687671
62-
[mypy-distutils.*,jaraco.develop,jaraco.envs,jaraco.packaging.*,jaraco.path,jaraco.test.*,jaraco.text,wheel.*]
61+
[mypy-jaraco,jaraco.develop,jaraco.envs,jaraco.packaging.*,jaraco.path,jaraco.test.*,jaraco.text,wheel.*]
6362
ignore_missing_imports = True
6463

6564
# Even when excluding a module, import issues can show up due to following import

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ type = [
133133

134134
# local
135135

136+
# Referenced in distutils-stubs
137+
"types-docutils",
136138
# pin mypy version so a new version doesn't suddenly cause the CI to fail,
137139
# until types-setuptools is removed from typeshed.
138140
# For help with static-typing issues, or mypy update, ping @Avasam
@@ -203,6 +205,8 @@ include-package-data = true
203205
include = [
204206
"setuptools*",
205207
"pkg_resources*",
208+
# TODO: Include distutils stubs with package once we're confident in them
209+
# "typings/distutils-stubs",
206210
"_distutils_hack*",
207211
]
208212
exclude = [

pyrightconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
],
1313
// Our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually.
1414
// "pythonVersion": "3.8",
15+
// Allow using distutils-stubs on Python 3.12+
16+
"reportMissingModuleSource": false,
1517
// For now we don't mind if mypy's `type: ignore` comments accidentally suppresses pyright issues
1618
"enableTypeIgnoreComments": true,
1719
"typeCheckingMode": "basic",

ruff.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ ignore = [
3131
# Only enforcing return type annotations for public functions
3232
"ANN202", # missing-return-type-private-function
3333
"ANN204", # missing-return-type-special-method
34+
# Typeshed doesn't want complex or non-literal defaults for maintenance and testing reasons.
35+
# This doesn't affect us, let's have more complete stubs.
36+
"PYI011", # typed-argument-default-in-stub
3437

3538
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
3639
"W191",

setuptools/command/sdist.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import re
66
from itertools import chain
7+
from typing import ClassVar
78

89
from .._importlib import metadata
910
from ..dist import Distribution
@@ -49,7 +50,7 @@ class sdist(orig.sdist):
4950
]
5051

5152
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
52-
negative_opt: dict[str, str] = {}
53+
negative_opt: ClassVar[dict[str, str]] = {}
5354

5455
README_EXTENSIONS = ['', '.rst', '.txt', '.md']
5556
READMES = tuple('README{0}'.format(ext) for ext in README_EXTENSIONS)

0 commit comments

Comments
 (0)