Debian Codegraph @

pyproject.toml

raw ◀ ▶
1 Debian patch touch this file
1 [build-system]
2 requires = [
3 # NOTE: this needs to be kept in sync with mypy-requirements.txt
4 # and build-requirements.txt, because those are both needed for
5 # self-typechecking :/
6 "setuptools >= 77.0.3",
7 # the following is from mypy-requirements.txt/setup.py
8 "typing_extensions>=4.6.0; python_version<'3.15'",
9 "typing_extensions>=4.14.0; python_version>='3.15'",
10 "mypy_extensions>=1.0.0",
11 "pathspec>=1.0.0",
12 "tomli>=1.1.0; python_version<'3.11'",
13 "librt>=0.13.0; platform_python_implementation != 'PyPy'",
14 # the following is from build-requirements.txt
15 "types-psutil",
16 "types-setuptools",
17 # required to work around a mypyc import bug
•18 "ast-serialize>=0.9.0,<1.0.0",
19 ]
20 build-backend = "setuptools.build_meta"
21
22 [project]
23 name = "mypy"
24 description = "Optional static typing for Python"
25 readme = {text = """
26 Mypy -- Optional Static Typing for Python
27 =========================================
28
29 Add type annotations to your Python programs, and use mypy to type
30 check them. Mypy is essentially a Python linter on steroids, and it
31 can catch many programming errors by analyzing your program, without
32 actually having to run it. Mypy has a powerful type system with
33 features such as type inference, gradual typing, generics and union
34 types.
35 """, content-type = "text/x-rst"}
36 authors = [{name = "Jukka Lehtosalo", email = "[email protected]"}]
37 license = "MIT"
38 license-files = ["LICENSE", "mypy/typeshed/LICENSE"]
39 classifiers = [
40 "Development Status :: 5 - Production/Stable",
41 "Environment :: Console",
42 "Intended Audience :: Developers",
43 "Programming Language :: Python :: 3",
44 "Programming Language :: Python :: 3.10",
45 "Programming Language :: Python :: 3.11",
46 "Programming Language :: Python :: 3.12",
47 "Programming Language :: Python :: 3.13",
48 "Programming Language :: Python :: 3.14",
49 "Programming Language :: Python :: 3.15",
50 "Topic :: Software Development",
51 "Typing :: Typed",
52 ]
53 requires-python = ">=3.10"
54 dependencies = [
55 # When changing this, also update build-system.requires and mypy-requirements.txt
56 "typing_extensions>=4.6.0; python_version<'3.15'",
57 "typing_extensions>=4.14.0; python_version>='3.15'",
58 "mypy_extensions>=1.0.0",
59 "pathspec>=1.0.0",
60 "tomli>=1.1.0; python_version<'3.11'",
61 "librt>=0.13.0; platform_python_implementation != 'PyPy'",
•62 "ast-serialize>=0.9.0,<1.0.0",
63 ]
64 dynamic = ["version"]
65
66 [project.optional-dependencies]
67 dmypy = ["psutil>=4.0"]
68 mypyc = ["setuptools>=50"]
69 reports = ["lxml"]
70 install-types = ["pip"]
71 faster-cache = ["orjson"]
72 native-parser = []
73
74 [project.urls]
75 Homepage = "https://www.mypy-lang.org/"
76 Documentation = "https://mypy.readthedocs.io/en/stable/index.html"
77 Repository = "https://github.com/python/mypy"
78 Changelog = "https://github.com/python/mypy/blob/master/CHANGELOG.md"
79 Issues = "https://github.com/python/mypy/issues"
80
81 [project.scripts]
82 mypy = "mypy.__main__:console_entry"
83 stubgen = "mypy.stubgen:main"
84 stubtest = "mypy.stubtest:main"
85 dmypy = "mypy.dmypy.client:console_entry"
86 mypyc = "mypyc.__main__:main"
87
88 [tool.setuptools.packages.find]
89 include = ["mypy*", "mypyc*", "*__mypyc*"]
90 exclude = ["mypyc.test-data*"]
91 namespaces = false
92
93 [tool.setuptools.package-data]
94 mypy = [
95 "py.typed",
96 "typeshed/**/*.py",
97 "typeshed/**/*.pyi",
98 "typeshed/stdlib/VERSIONS",
99 "xml/*.xsd",
100 "xml/*.xslt",
101 "xml/*.css",
102 ]
103 [tool.setuptools.exclude-package-data]
104 mypyc = [
105 "README.md",
106 "doc/**",
107 "external/**",
108 "lib-rt/test_capi.cc",
109 "lib-rt/setup.py",
110 "test-data/**",
111 ]
112
113 [tool.black]
114 line-length = 99
115 target-version = ["py310", "py311", "py312", "py313", "py314"]
116 skip-magic-trailing-comma = true
117 force-exclude = '''
118 ^/mypy/typeshed|
119 ^/mypyc/test-data|
120 ^/test-data
121 '''
122
123 [tool.ruff]
124 line-length = 99
125 target-version = "py310"
126 fix = true
127
128 extend-exclude = [
129 "@*",
130 # Sphinx configuration is irrelevant
131 "docs/source/conf.py",
132 "mypyc/doc/conf.py",
133 # tests have more relaxed styling requirements
134 # fixtures have their own .pyi-specific configuration
135 "test-data/*",
136 "mypyc/test-data/*",
137 # typeshed has its own .pyi-specific configuration
138 "mypy/typeshed/*",
139 ]
140
141 [tool.ruff.lint]
142 select = [
143 "E", # pycodestyle (error)
144 "F", # pyflakes
145 "W", # pycodestyle (warning)
146 "B", # flake8-bugbear
147 "I", # isort
148 "N", # pep8-naming
149 "PIE", # flake8-pie
150 "PLE", # pylint error
151 "RUF100", # Unused noqa comments
152 "PGH004", # blanket noqa comments
153 "UP", # pyupgrade
154 "C4", # flake8-comprehensions
155 "SIM101", # merge duplicate isinstance calls
156 "SIM201", "SIM202", "SIM222", "SIM223", # flake8-simplify
157 "FURB168", # Prefer is operator over isinstance for None checks
158 "FURB169", # Do not use is comparison with type(None). Use None
159 "FURB187", # avoid list reverse copy
160 "FURB188", # use str.remove(pre|suf)fix
161 "ISC001", # implicitly concatenated string
162 "RET501", "RET502", # better return None handling
163 ]
164
165 ignore = [
166 "B007", # Loop control variable not used within the loop body.
167 "B011", # Don't use assert False
168 "B023", # Function definition does not bind loop variable
169 "B905", # zip-without-explicit-strict
170 "E2", # conflicts with black
171 "E402", # module level import not at top of file
172 "E501", # conflicts with black
173 "E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
174 "E731", # Do not assign a `lambda` expression, use a `def`
175 "E741", # Ambiguous variable name
176 "N818", # Exception should be named with an Error suffix
177 "N806", # UPPER_CASE used for constant local variables
178 "UP031", # Use format specifiers instead of percent format
179 "UP032", # 'f-string always preferable to format' is controversial
180 "C409", # https://github.com/astral-sh/ruff/issues/12912
181 "C420", # reads a little worse. fromkeys predates dict comprehensions
182 "C416", # There are a few cases where it's nice to have names for the dict items
183 "PIE790", # there's nothing wrong with pass
184 ]
185
186 unfixable = [
187 "F841", # unused variable. ruff keeps the call, but mostly we want to get rid of it all
188 "F601", # automatic fix might obscure issue
189 "F602", # automatic fix might obscure issue
190 "B018", # automatic fix might obscure issue
191 "UP036", # sometimes it's better to just noqa this
192 "SIM222", # automatic fix might obscure issue
193 "SIM223", # automatic fix might obscure issue
194 ]
195
196 [tool.ruff.lint.per-file-ignores]
197 # Mixed case variable and function names.
198 "mypy/fastparse.py" = ["N802", "N816"]
199
200 [tool.ruff.lint.isort]
201 combine-as-imports = true
202 extra-standard-library = ["typing_extensions"]
203
204 [tool.check-manifest]
205 ignore = ["**/.readthedocs.yaml"]
206
207 [tool.pytest.ini_options]
208 minversion = "7.0.0"
209 testpaths = ["mypy/test", "mypyc/test"]
210 python_files = 'test*.py'
211
212 # Where do the test cases come from? We provide our own collection
213 # logic by implementing `pytest_pycollect_makeitem` in mypy.test.data;
214 # the test files import that module, and pytest sees the magic name
215 # and invokes it at the relevant moment. See
216 # https://doc.pytest.org/en/latest/how-to/writing_plugins.html#collection-hooks
217
218 # Both our plugin and unittest provide their own collection logic,
219 # So we can disable the default python collector by giving it empty
220 # patterns to search for.
221 # Note that unittest requires that no "Test*" classes exist.
222 python_classes = []
223 python_functions = []
224
225 # always run in parallel (requires pytest-xdist, see test-requirements.txt)
226 # and enable strict mode: require all markers
227 # to be defined and raise on invalid config values
228 addopts = "-nauto --strict-markers --strict-config"
229
230 # treat xpasses as test failures so they get converted to regular tests as soon as possible
231 xfail_strict = true
232
233 # Force warnings as errors
234 filterwarnings = [
235 "error",
236 ]
237
238 [tool.coverage.run]
239 branch = true
240 source = ["mypy"]
241 parallel = true
242
243 [tool.coverage.report]
244 show_missing = true
245 skip_covered = true
246 omit = ['mypy/test/*']
247 exclude_lines = [
248 '\#\s*pragma: no cover',
249 '^\s*raise AssertionError\b',
250 '^\s*raise NotImplementedError\b',
251 '^\s*return NotImplemented\b',
252 '^\s*raise$',
253 '^assert False\b',
254 '''^if __name__ == ['"]__main__['"]:$''',
255 ]