forked from microsoft/python-type-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
174 lines (156 loc) · 5.29 KB
/
pyproject.toml
File metadata and controls
174 lines (156 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
[build-system]
requires = ["setuptools >= 69.0"] # v69 includes type information by default
build-backend = "setuptools.build_meta"
[project]
name = "microsoft-python-type-stubs"
version = "0"
[dependency-groups]
hygiene = ["ruff ==0.11.*"]
tests = [
# Tools used for testing
"docopt-ng",
"mypy ==1.15.*",
"pyright",
# Typed libraries and stubs
"matplotlib >=3.8",
"numpy >=2",
"pandas-stubs",
"pytest",
"scipy-stubs",
"typing_extensions",
# Untyped libraries. Used to prevent "reportMissingImports" and get inferred typing
"joblib",
"PyOpenGL",
"traitlets",
"transformers",
# The libraries we're stubbing. Needed for stubtest
"networkx",
"scikit-image",
"scikit-learn",
"sympy",
"vispy",
]
dev = [{ include-group = "hygiene" }, { include-group = "tests" }]
# Allow these stubs to be installed from GitHub
# We need an explicit mapping instead of just
# [tool.setuptools]
# package-dir = {"" = "stubs"}
# because the folder names don't all match "*-stubs"
# see https://github.com/microsoft/python-type-stubs/issues/315
[tool.setuptools.package-dir]
# See README.md as to why matplotlib is not included
"networkx-stubs" = "stubs/networkx"
"skimage-stubs" = "stubs/skimage"
"sklearn-stubs" = "stubs/sklearn"
"sympy-stubs" = "stubs/sympy-stubs"
"transformers-stubs" = "stubs/transformers-stubs"
"vispy-stubs" = "stubs/vispy"
[tool.ruff]
line-length = 130
# Target oldest supported Python version
target-version = "py39"
[tool.ruff.lint]
extend-select = [
"FA", # flake8-future-annotations
"I", # isort
"ICN", # flake8-import-conventions
"PYI", # flake8-pyi
"UP", # pyupgrade
"W", # pycodestyle Warning
"PIE790", # unnecessary-placeholder
]
ignore = [
###
# Rules we don't want or don't agree with
###
# Used for direct, non-subclass type comparison, for example: `type(val) is str`
# see https://github.com/astral-sh/ruff/issues/6465
"E721", # Do not compare types, use `isinstance()`
# Typeshed doesn't want complex or non-literal defaults, or long strings, for maintenance and testing reasons.
# This doesn't affect us, let's have more complete stubs.
"PYI011",
"PYI014",
"PYI053",
# TODO: Fixing these would change which symbols are even visible for Pylance.
# Which may negatively affect users, especially if the symbol wasn't meant to be re-exported.
# Manually evaluate each violation.
"F401",
# TODO: Investigate and fix or configure
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
]
[tool.ruff.lint.per-file-ignores]
"*.pyi" = [
###
# Rules that are out of the control of stub authors:
###
"E743", # Ambiguous function name; stubs must follow implementation
"F403", # `from . import *` used; unable to detect undefined names
# Stubs can sometimes re-export entire modules.
# Issues with using a star-imported name will be caught by type-checkers.
"F405", # may be undefined, or defined from star imports
]
# We keep docstrings in sklearn
"stubs/sklearn/**" = ["PYI021"]
[tool.ruff.lint.flake8-import-conventions.aliases]
# Prevent aliasing these, as it causes false-negatives for certain rules
typing_extensions = "typing_extensions"
typing = "typing"
[tool.ruff.lint.isort]
combine-as-imports = true
extra-standard-library = [
# Group these with stdlib
"typing_extensions",
"_typeshed",
# Extra modules not recognized by Ruff
# Added in Python 3.9
"zoneinfo",
# Added in Python 3.14
"compression",
]
[tool.pyright]
exclude = ["build", ".git"]
stubPath = "./stubs"
pythonversion = "3.9" # Target oldest supported Python version
typeCheckingMode = "standard"
# Partial stubs are acceptable
reportUnknownArgumentType = false
# Stubs-only packages are fine for testing
reportMissingModuleSource = false
# Stubs are allowed to use private variables
reportPrivateUsage = false
reportPrivateImportUsage = false
# Incompatible overrides and property type mismatches are out of our stubs' control
# as they are inherited from the implementation.
reportIncompatibleMethodOverride = false
reportIncompatibleVariableOverride = false
reportPropertyTypeMismatch = false
# Overlapping overloads are often necessary in a stub, meaning pyright's check
# (which is stricter than mypy's; see mypy issue #10143 and #10157)
# would cause many false positives and catch few bugs.
reportOverlappingOverload = false
# The name of the self/cls parameter is out of third-party stubs' control.
reportSelfClsParameterName = false
# Not an error by default in standard mode
reportUnsupportedDunderAll = "error"
[tool.mypy]
python_version = "3.9" # Target oldest supported Python version
strict = true
check_untyped_defs = true # Strict check on all defs
show_column_numbers = true
warn_unused_ignores = false # Change from pandas
# Partial stubs are acceptable
disallow_any_generics = false
disallow_incomplete_defs = false
disallow_untyped_defs = false
# Suppressing errors
disable_error_code = [
# Not all imports in these stubs are gonna be typed
"import-untyped",
# TODO
"valid-type", # 967 errors in 115 files
"override", # 790 errors in 220 files
"assignment", # 773 errors in 172 files
"misc", # 692 errors in 132 files
"attr-defined", # 202 errors in 75 files
"assert-type", # 6 errors in 1 file
]