Skip to content

Commit 3280eec

Browse files
committed
Merge remote-tracking branch 'upstream/master' into add-main-2
2 parents 142813d + 6cd8c00 commit 3280eec

File tree

364 files changed

+11489
-3854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

364 files changed

+11489
-3854
lines changed

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
97c5ee99bc98dc475512e549b252b23a6e7e0997
33
# Use builtin generics and PEP 604 for type annotations wherever possible (#13427)
44
23ee1e7aff357e656e3102435ad0fe3b5074571e
5+
# Use variable annotations (#10723)
6+
f98f78216ba9d6ab68c8e69c19e9f3c7926c5efe

.github/ISSUE_TEMPLATE/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ contact_links:
22
- about: "Please check the linked documentation page before filing new issues."
33
name: "Common issues and solutions"
44
url: "https://mypy.readthedocs.io/en/stable/common_issues.html"
5-
- about: "Please ask and answer any questions on the mypy Gitter."
5+
- about: "Please ask and answer any questions on the python/typing Gitter."
66
name: "Questions or Chat"
77
url: "https://gitter.im/python/typing"

.github/workflows/build_wheels.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v3
1414
- uses: actions/setup-python@v4
1515
with:
16-
python-version: '3.7'
16+
python-version: '3.11'
1717
- name: Trigger script
1818
env:
1919
WHEELS_PUSH_TOKEN: ${{ secrets.WHEELS_PUSH_TOKEN }}

.github/workflows/docs.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ jobs:
2020
env:
2121
TOXENV: docs
2222
TOX_SKIP_MISSING_INTERPRETERS: False
23+
VERIFY_MYPY_ERROR_CODES: 1
2324
steps:
2425
- uses: actions/checkout@v3
2526
- uses: actions/setup-python@v4
2627
with:
27-
python-version: '3.7'
28+
python-version: '3.8'
2829
- name: Install tox
2930
run: pip install --upgrade 'setuptools!=50' tox==4.4.4
3031
- name: Setup tox environment

.github/workflows/test.yml

+22-29
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,27 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
include:
29-
- name: Test suite with py37-windows-64
30-
python: '3.7'
31-
arch: x64
32-
os: windows-latest
33-
toxenv: py37
34-
- name: Test suite with py38-ubuntu
29+
# Make sure to run mypyc compiled unit tests for both
30+
# the oldest and newest supported Python versions
31+
- name: Test suite with py38-ubuntu, mypyc-compiled
3532
python: '3.8'
3633
arch: x64
3734
os: ubuntu-latest
3835
toxenv: py
3936
tox_extra_args: "-n 2"
40-
- name: Test suite with py39-ubuntu
41-
python: '3.9'
42-
arch: x64
43-
os: ubuntu-latest
44-
toxenv: py
45-
tox_extra_args: "-n 2"
46-
- name: Test suite with py37-ubuntu, mypyc-compiled
47-
python: '3.7'
37+
test_mypyc: true
38+
- name: Test suite with py38-windows-64
39+
python: '3.8'
4840
arch: x64
49-
os: ubuntu-latest
50-
toxenv: py
41+
os: windows-latest
42+
toxenv: py38
5143
tox_extra_args: "-n 2"
52-
test_mypyc: true
53-
- name: Test suite with py310-ubuntu, mypyc-compiled
54-
python: '3.10'
44+
- name: Test suite with py39-ubuntu
45+
python: '3.9'
5546
arch: x64
5647
os: ubuntu-latest
5748
toxenv: py
5849
tox_extra_args: "-n 2"
59-
test_mypyc: true
6050
- name: Test suite with py310-ubuntu
6151
python: '3.10'
6252
arch: x64
@@ -70,33 +60,36 @@ jobs:
7060
toxenv: py
7161
tox_extra_args: "-n 2"
7262
test_mypyc: true
73-
- name: mypyc runtime tests with py37-macos
74-
python: '3.7'
63+
64+
- name: mypyc runtime tests with py38-macos
65+
python: '3.8.17'
7566
arch: x64
7667
os: macos-latest
7768
toxenv: py
7869
tox_extra_args: "-n 2 mypyc/test/test_run.py mypyc/test/test_external.py"
79-
- name: mypyc runtime tests with py37-debug-build-ubuntu
80-
python: '3.7.13'
70+
- name: mypyc runtime tests with py38-debug-build-ubuntu
71+
python: '3.8.17'
8172
arch: x64
8273
os: ubuntu-latest
8374
toxenv: py
8475
tox_extra_args: "-n 2 mypyc/test/test_run.py mypyc/test/test_external.py"
8576
debug_build: true
86-
- name: Type check our own code (py37-ubuntu)
87-
python: '3.7'
77+
78+
- name: Type check our own code (py38-ubuntu)
79+
python: '3.8'
8880
arch: x64
8981
os: ubuntu-latest
9082
toxenv: type
91-
- name: Type check our own code (py37-windows-64)
92-
python: '3.7'
83+
- name: Type check our own code (py38-windows-64)
84+
python: '3.8'
9385
arch: x64
9486
os: windows-latest
9587
toxenv: type
88+
9689
# We also run these checks with pre-commit in CI,
9790
# but it's useful to run them with tox too,
9891
# to ensure the tox env works as expected
99-
- name: Formatting with Black + isort and code style with flake8
92+
- name: Formatting and code style with Black + ruff
10093
python: '3.10'
10194
arch: x64
10295
os: ubuntu-latest

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,5 @@ test_capi
5757
*.o
5858
*.a
5959
test_capi
60-
/.mypyc-flake8-cache.json
6160
/mypyc/lib-rt/build/
6261
/mypyc/lib-rt/*.so

.pre-commit-config.yaml

+5-15
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,12 @@ repos:
55
hooks:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
8-
- repo: https://github.com/psf/black
8+
- repo: https://github.com/hauntsaninja/black-pre-commit-mirror
99
rev: 23.3.0 # must match test-requirements.txt
1010
hooks:
1111
- id: black
12-
- repo: https://github.com/pycqa/isort
13-
rev: 5.12.0 # must match test-requirements.txt
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.0.272 # must match test-requirements.txt
1414
hooks:
15-
- id: isort
16-
- repo: https://github.com/pycqa/flake8
17-
rev: 6.0.0 # must match test-requirements.txt
18-
hooks:
19-
- id: flake8
20-
additional_dependencies:
21-
- flake8-bugbear==23.3.23 # must match test-requirements.txt
22-
- flake8-noqa==1.3.1 # must match test-requirements.txt
23-
24-
ci:
25-
# We run flake8 as part of our GitHub Actions suite in CI
26-
skip: [flake8]
15+
- id: ruff
16+
args: [--exit-non-zero-on-fix]

.readthedocs.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
version: 2
5+
6+
build:
7+
os: ubuntu-22.04
8+
tools:
9+
python: "3.11"
10+
11+
sphinx:
12+
configuration: docs/source/conf.py
13+
14+
formats: [pdf, htmlzip, epub]
15+
16+
python:
17+
install:
18+
- requirements: docs/requirements-docs.txt

CONTRIBUTING.md

+2-9
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,8 @@ pytest -n0 -k 'test_name'
8888
# Run all test cases in the "test-data/unit/check-dataclasses.test" file
8989
pytest mypy/test/testcheck.py::TypeCheckSuite::check-dataclasses.test
9090

91-
# Run the linter
92-
flake8
93-
94-
# Run formatters
95-
black . && isort .
91+
# Run the formatters and linters
92+
python runtests.py lint
9693
```
9794

9895
For an in-depth guide on running and writing tests,
@@ -154,10 +151,6 @@ advice about good pull requests for open-source projects applies; we
154151
have [our own writeup](https://github.com/python/mypy/wiki/Good-Pull-Request)
155152
of this advice.
156153

157-
We are using `black` and `isort` to enforce a consistent coding style.
158-
Run `black . && isort .` before your commits, otherwise you would receive
159-
a CI failure.
160-
161154
Also, do not squash your commits after you have submitted a pull request, as this
162155
erases context during review. We will squash commits when the pull request is merged.
163156

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Mypy: Static Typing for Python
1010
[![Chat at https://gitter.im/python/typing](https://badges.gitter.im/python/typing.svg)](https://gitter.im/python/typing?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1111
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
1212
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
13-
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
13+
[![Linting: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
1414

1515
Got a question?
1616
---------------

build-requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
-r mypy-requirements.txt
33
types-psutil
44
types-setuptools
5-
types-typed-ast>=1.5.8.5,<1.6.0

docs/source/additional_features.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ of the previous sections.
99
Dataclasses
1010
***********
1111

12-
In Python 3.7, a new :py:mod:`dataclasses` module has been added to the standard library.
13-
This module allows defining and customizing simple boilerplate-free classes.
14-
They can be defined using the :py:func:`@dataclasses.dataclass
15-
<python:dataclasses.dataclass>` decorator:
12+
The :py:mod:`dataclasses` module allows defining and customizing simple
13+
boilerplate-free classes. They can be defined using the
14+
:py:func:`@dataclasses.dataclass <python:dataclasses.dataclass>` decorator:
1615

1716
.. code-block:: python
1817

docs/source/cheat_sheet_py3.rst

-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ Classes
178178
class AuditedBankAccount(BankAccount):
179179
# You can optionally declare instance variables in the class body
180180
audit_log: list[str]
181-
# This is an instance variable with a default value
182-
auditor_name: str = "The Spanish Inquisition"
183181
184182
def __init__(self, account_name: str, initial_balance: int = 0) -> None:
185183
super().__init__(account_name, initial_balance)

docs/source/command_line.rst

+28
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,34 @@ of the above sections.
612612
613613
assert text is not None # OK, check against None is allowed as a special case.
614614
615+
.. option:: --extra-checks
616+
617+
This flag enables additional checks that are technically correct but may be
618+
impractical in real code. In particular, it prohibits partial overlap in
619+
``TypedDict`` updates, and makes arguments prepended via ``Concatenate``
620+
positional-only. For example:
621+
622+
.. code-block:: python
623+
624+
from typing import TypedDict
625+
626+
class Foo(TypedDict):
627+
a: int
628+
629+
class Bar(TypedDict):
630+
a: int
631+
b: int
632+
633+
def test(foo: Foo, bar: Bar) -> None:
634+
# This is technically unsafe since foo can have a subtype of Foo at
635+
# runtime, where type of key "b" is incompatible with int, see below
636+
bar.update(foo)
637+
638+
class Bad(Foo):
639+
b: str
640+
bad: Bad = {"a": 0, "b": "no"}
641+
test(bad, bar)
642+
615643
.. option:: --strict
616644

617645
This flag mode enables all optional error checking flags. You can see the

docs/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# Add any Sphinx extension module names here, as strings. They can be
3636
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3737
# ones.
38-
extensions = ["sphinx.ext.intersphinx"]
38+
extensions = ["sphinx.ext.intersphinx", "docs.source.html_builder"]
3939

4040
# Add any paths that contain templates here, relative to this directory.
4141
templates_path = ["_templates"]

docs/source/config_file.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ section of the command line docs.
366366

367367
.. confval:: no_site_packages
368368

369-
:type: bool
369+
:type: boolean
370370
:default: False
371371

372372
Disables using type information in installed packages (see :pep:`561`).

0 commit comments

Comments
 (0)