Skip to content

Commit 45242d8

Browse files
Merge branch 'master' into msg-regostry-checkstrformat
2 parents 91c46c7 + 9e7bc38 commit 45242d8

File tree

320 files changed

+7880
-2638
lines changed

Some content is hidden

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

320 files changed

+7880
-2638
lines changed

.git-blame-ignore-revs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# Adopt black and isort
2-
97c5ee99bc98dc475512e549b252b23a6e7e0997
2+
97c5ee99bc98dc475512e549b252b23a6e7e0997
3+
# Use builtin generics and PEP 604 for type annotations wherever possible (#13427)
4+
23ee1e7aff357e656e3102435ad0fe3b5074571e
5+
# Use variable annotations (#10723)
6+
f98f78216ba9d6ab68c8e69c19e9f3c7926c5efe

.github/workflows/build_wheels.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Trigger wheel build
22

33
on:
44
push:
5-
branches: [master, 'release*']
5+
branches: [main, master, 'release*']
66
tags: ['*']
77

88
jobs:

.github/workflows/docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Check documentation build
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [master, 'release*']
6+
branches: [main, master, 'release*']
77
tags: ['*']
88
pull_request:
99
paths:

.github/workflows/mypy_primer_comment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
if (data.trim()) {
7979
body = 'Diff from [mypy_primer](https://github.com/hauntsaninja/mypy_primer), showing the effect of this PR on open source code:\n```diff\n' + data + '```'
8080
} else {
81-
body = 'According to [mypy_primer](https://github.com/hauntsaninja/mypy_primer), this change has no effect on the checked open source code. 🤖🎉'
81+
body = "According to [mypy_primer](https://github.com/hauntsaninja/mypy_primer), this change doesn't affect type check results on a corpus of open source code. ✅"
8282
}
8383
const prNumber = parseInt(fs.readFileSync("pr_number.txt", { encoding: "utf8" }))
8484
await github.rest.issues.createComment({

.github/workflows/test.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Tests
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [master, 'release*']
6+
branches: [main, master, 'release*']
77
tags: ['*']
88
pull_request:
99
paths-ignore:
@@ -93,8 +93,11 @@ jobs:
9393
arch: x64
9494
os: windows-latest
9595
toxenv: type
96+
# We also run these checks with pre-commit in CI,
97+
# but it's useful to run them with tox too,
98+
# to ensure the tox env works as expected
9699
- name: Formatting with Black + isort and code style with flake8
97-
python: '3.7'
100+
python: '3.10'
98101
arch: x64
99102
os: ubuntu-latest
100103
toxenv: lint
@@ -180,6 +183,7 @@ jobs:
180183
sudo dpkg --add-architecture i386 && \
181184
sudo apt-get update && sudo apt-get install -y \
182185
zlib1g-dev:i386 \
186+
libgcc-s1:i386 \
183187
g++-i686-linux-gnu \
184188
gcc-i686-linux-gnu \
185189
libffi-dev:i386 \

.github/workflows/test_stubgenc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test stubgenc on pybind11-mypy-demo
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [master, 'release*']
6+
branches: [main, master, 'release*']
77
tags: ['*']
88
pull_request:
99
paths:

.pre-commit-config.yaml

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1+
exclude: '^(mypyc/external/)|(mypy/typeshed/)' # Exclude all vendored code from lints
12
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.4.0 # must match test-requirements.txt
5+
hooks:
6+
- id: trailing-whitespace
7+
- id: end-of-file-fixer
28
- repo: https://github.com/psf/black
39
rev: 23.3.0 # must match test-requirements.txt
410
hooks:
511
- id: black
612
- repo: https://github.com/pycqa/isort
7-
rev: 5.11.5 # must match test-requirements.txt
13+
rev: 5.12.0 # must match test-requirements.txt
814
hooks:
915
- id: isort
1016
- repo: https://github.com/pycqa/flake8
11-
rev: 5.0.4 # must match test-requirements.txt
17+
rev: 6.0.0 # must match test-requirements.txt
1218
hooks:
1319
- id: flake8
1420
additional_dependencies:
15-
- flake8-bugbear==22.12.6 # must match test-requirements.txt
16-
- flake8-noqa==1.3.0 # must match test-requirements.txt
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]

CONTRIBUTING.md

+36-23
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,42 @@ issue tracker, pull requests, and chat, is expected to treat
1212
other people with respect and more generally to follow the guidelines
1313
articulated in the [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/).
1414

15-
1615
## Getting started with development
1716

1817
### Setup
1918

20-
#### (1) Clone the mypy repository and enter into it
21-
```
22-
git clone https://github.com/python/mypy.git
19+
#### (1) Fork the mypy repository
20+
21+
Within Github, navigate to <https://github.com/python/mypy> and fork the repository.
22+
23+
#### (2) Clone the mypy repository and enter into it
24+
25+
```bash
26+
git clone [email protected]:<your_username>/mypy.git
2327
cd mypy
2428
```
2529

26-
#### (2) Create then activate a virtual environment
27-
```
30+
#### (3) Create then activate a virtual environment
31+
32+
```bash
2833
# On Windows, the commands may be slightly different. For more details, see
2934
# https://docs.python.org/3/library/venv.html#creating-virtual-environments
3035
python3 -m venv venv
3136
source venv/bin/activate
3237
```
3338

34-
#### (3) Install the test requirements and the project
35-
```
39+
#### (4) Install the test requirements and the project
40+
41+
```bash
3642
python3 -m pip install -r test-requirements.txt
3743
python3 -m pip install -e .
3844
hash -r # This resets shell PATH cache, not necessary on Windows
3945
```
4046

47+
> **Note**
48+
> You'll need Python 3.8 or higher to install all requirements listed in
49+
> test-requirements.txt
50+
4151
### Running tests
4252

4353
Running the full test suite can take a while, and usually isn't necessary when
@@ -47,12 +57,14 @@ your PR.
4757

4858
However, if you wish to do so, you can run the full test suite
4959
like this:
50-
```
60+
61+
```bash
5162
python3 runtests.py
5263
```
5364

5465
You can also use `tox` to run tests (`tox` handles setting up the test environment for you):
55-
```
66+
67+
```bash
5668
tox run -e py
5769

5870
# Or some specific python version:
@@ -63,6 +75,7 @@ tox run -e lint
6375
```
6476

6577
Some useful commands for running specific tests include:
78+
6679
```bash
6780
# Use mypy to check mypy's own code
6881
python3 runtests.py self
@@ -90,6 +103,7 @@ see [the README in the test-data directory](test-data/unit/README.md).
90103
If you're looking for things to help with, browse our [issue tracker](https://github.com/python/mypy/issues)!
91104

92105
In particular, look for:
106+
93107
- [good first issues](https://github.com/python/mypy/labels/good-first-issue)
94108
- [good second issues](https://github.com/python/mypy/labels/good-second-issue)
95109
- [documentation issues](https://github.com/python/mypy/labels/documentation)
@@ -151,28 +165,27 @@ You may also find other pages in the
151165
[Mypy developer guide](https://github.com/python/mypy/wiki/Developer-Guides)
152166
helpful in developing your change.
153167

154-
155168
## Core developer guidelines
156169

157170
Core developers should follow these rules when processing pull requests:
158171

159-
* Always wait for tests to pass before merging PRs.
160-
* Use "[Squash and merge](https://github.com/blog/2141-squash-your-commits)"
172+
- Always wait for tests to pass before merging PRs.
173+
- Use "[Squash and merge](https://github.com/blog/2141-squash-your-commits)"
161174
to merge PRs.
162-
* Delete branches for merged PRs (by core devs pushing to the main repo).
163-
* Edit the final commit message before merging to conform to the following
175+
- Delete branches for merged PRs (by core devs pushing to the main repo).
176+
- Edit the final commit message before merging to conform to the following
164177
style (we wish to have a clean `git log` output):
165-
* When merging a multi-commit PR make sure that the commit message doesn't
178+
- When merging a multi-commit PR make sure that the commit message doesn't
166179
contain the local history from the committer and the review history from
167180
the PR. Edit the message to only describe the end state of the PR.
168-
* Make sure there is a *single* newline at the end of the commit message.
181+
- Make sure there is a *single* newline at the end of the commit message.
169182
This way there is a single empty line between commits in `git log`
170183
output.
171-
* Split lines as needed so that the maximum line length of the commit
184+
- Split lines as needed so that the maximum line length of the commit
172185
message is under 80 characters, including the subject line.
173-
* Capitalize the subject and each paragraph.
174-
* Make sure that the subject of the commit message has no trailing dot.
175-
* Use the imperative mood in the subject line (e.g. "Fix typo in README").
176-
* If the PR fixes an issue, make sure something like "Fixes #xxx." occurs
186+
- Capitalize the subject and each paragraph.
187+
- Make sure that the subject of the commit message has no trailing dot.
188+
- Use the imperative mood in the subject line (e.g. "Fix typo in README").
189+
- If the PR fixes an issue, make sure something like "Fixes #xxx." occurs
177190
in the body of the message (not in the subject).
178-
* Use Markdown for formatting.
191+
- Use Markdown for formatting.

README.md

+36-26
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ To report a bug or request an enhancement:
4040
tracker for that library
4141

4242
To discuss a new type system feature:
43+
4344
- discuss at [typing-sig mailing list](https://mail.python.org/archives/list/[email protected]/)
4445
- there is also some historical discussion [here](https://github.com/python/typing/issues)
4546

46-
4747
What is mypy?
4848
-------------
4949

@@ -82,6 +82,7 @@ See [the documentation](https://mypy.readthedocs.io/en/stable/index.html) for
8282
more examples and information.
8383

8484
In particular, see:
85+
8586
- [type hints cheat sheet](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html)
8687
- [getting started](https://mypy.readthedocs.io/en/stable/getting_started.html)
8788
- [list of error codes](https://mypy.readthedocs.io/en/stable/error_code_list.html)
@@ -91,67 +92,75 @@ Quick start
9192

9293
Mypy can be installed using pip:
9394

94-
python3 -m pip install -U mypy
95+
```bash
96+
python3 -m pip install -U mypy
97+
```
9598

9699
If you want to run the latest version of the code, you can install from the
97100
repo directly:
98101

99-
python3 -m pip install -U git+https://github.com/python/mypy.git
100-
# or if you don't have 'git' installed
101-
python3 -m pip install -U https://github.com/python/mypy/zipball/master
102+
```bash
103+
python3 -m pip install -U git+https://github.com/python/mypy.git
104+
# or if you don't have 'git' installed
105+
python3 -m pip install -U https://github.com/python/mypy/zipball/master
106+
```
102107

103108
Now you can type-check the [statically typed parts] of a program like this:
104109

105-
mypy PROGRAM
110+
```bash
111+
mypy PROGRAM
112+
```
106113

107114
You can always use the Python interpreter to run your statically typed
108115
programs, even if mypy reports type errors:
109116

110-
python3 PROGRAM
117+
```bash
118+
python3 PROGRAM
119+
```
111120

112121
You can also try mypy in an [online playground](https://mypy-play.net/) (developed by
113122
Yusuke Miyazaki). If you are working with large code bases, you can run mypy in
114123
[daemon mode], that will give much faster (often sub-second) incremental updates:
115124

116-
dmypy run -- PROGRAM
125+
```bash
126+
dmypy run -- PROGRAM
127+
```
117128

118129
[statically typed parts]: https://mypy.readthedocs.io/en/latest/getting_started.html#function-signatures-and-dynamic-vs-static-typing
119130
[daemon mode]: https://mypy.readthedocs.io/en/stable/mypy_daemon.html
120131

121-
122132
Integrations
123133
------------
124134

125135
Mypy can be integrated into popular IDEs:
126136

127-
* Vim:
128-
* Using [Syntastic](https://github.com/vim-syntastic/syntastic): in `~/.vimrc` add
137+
- Vim:
138+
- Using [Syntastic](https://github.com/vim-syntastic/syntastic): in `~/.vimrc` add
129139
`let g:syntastic_python_checkers=['mypy']`
130-
* Using [ALE](https://github.com/dense-analysis/ale): should be enabled by default when `mypy` is installed,
140+
- Using [ALE](https://github.com/dense-analysis/ale): should be enabled by default when `mypy` is installed,
131141
or can be explicitly enabled by adding `let b:ale_linters = ['mypy']` in `~/vim/ftplugin/python.vim`
132-
* Emacs: using [Flycheck](https://github.com/flycheck/)
133-
* Sublime Text: [SublimeLinter-contrib-mypy](https://github.com/fredcallaway/SublimeLinter-contrib-mypy)
134-
* Atom: [linter-mypy](https://atom.io/packages/linter-mypy)
135-
* PyCharm: [mypy plugin](https://github.com/dropbox/mypy-PyCharm-plugin) (PyCharm integrates
142+
- Emacs: using [Flycheck](https://github.com/flycheck/)
143+
- Sublime Text: [SublimeLinter-contrib-mypy](https://github.com/fredcallaway/SublimeLinter-contrib-mypy)
144+
- Atom: [linter-mypy](https://atom.io/packages/linter-mypy)
145+
- PyCharm: [mypy plugin](https://github.com/dropbox/mypy-PyCharm-plugin) (PyCharm integrates
136146
[its own implementation](https://www.jetbrains.com/help/pycharm/type-hinting-in-product.html) of [PEP 484](https://peps.python.org/pep-0484/))
137-
* VS Code: provides [basic integration](https://code.visualstudio.com/docs/python/linting#_mypy) with mypy.
138-
* pre-commit: use [pre-commit mirrors-mypy](https://github.com/pre-commit/mirrors-mypy).
147+
- VS Code: provides [basic integration](https://code.visualstudio.com/docs/python/linting#_mypy) with mypy.
148+
- pre-commit: use [pre-commit mirrors-mypy](https://github.com/pre-commit/mirrors-mypy).
139149

140150
Web site and documentation
141151
--------------------------
142152

143153
Additional information is available at the web site:
144154

145-
https://www.mypy-lang.org/
155+
<https://www.mypy-lang.org/>
146156

147157
Jump straight to the documentation:
148158

149-
https://mypy.readthedocs.io/
159+
<https://mypy.readthedocs.io/>
150160

151161
Follow along our changelog at:
152162

153-
https://mypy-lang.blogspot.com/
154-
163+
<https://mypy-lang.blogspot.com/>
155164

156165
Contributing
157166
------------
@@ -164,7 +173,6 @@ To get started with developing mypy, see [CONTRIBUTING.md](CONTRIBUTING.md).
164173

165174
If you need help getting started, don't hesitate to ask on [gitter](https://gitter.im/python/typing).
166175

167-
168176
Mypyc and compiled version of mypy
169177
----------------------------------
170178

@@ -174,10 +182,12 @@ mypy approximately 4 times faster than if interpreted!
174182

175183
To install an interpreted mypy instead, use:
176184

177-
python3 -m pip install --no-binary mypy -U mypy
185+
```bash
186+
python3 -m pip install --no-binary mypy -U mypy
187+
```
178188

179189
To use a compiled version of a development
180190
version of mypy, directly install a binary from
181-
https://github.com/mypyc/mypy_mypyc-wheels/releases/latest.
191+
<https://github.com/mypyc/mypy_mypyc-wheels/releases/latest>.
182192

183-
To contribute to the mypyc project, check out https://github.com/mypyc/mypyc
193+
To contribute to the mypyc project, check out <https://github.com/mypyc/mypyc>

0 commit comments

Comments
 (0)