Skip to content

Commit 7c9090a

Browse files
Merge branch 'master' into pass-literals-as-kwargs
2 parents 837d6a0 + 24ef8d0 commit 7c9090a

File tree

1,124 files changed

+47226
-34177
lines changed

Some content is hidden

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

1,124 files changed

+47226
-34177
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*.{py,c,cpp,h,rst,md,yml,json,test}]
4+
trim_trailing_whitespace = true
5+
insert_final_newline = true
6+
indent_style = space
7+
8+
[*.{py,c,h,json,test}]
9+
indent_size = 4
10+
11+
[*.yml]
12+
indent_size = 2

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# We vendor typeshed from https://github.com/python/typeshed
2+
mypy/typeshed/** linguist-vendored

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
contact_links:
2+
- about: "Please check the linked documentation page before filing new issues."
3+
name: "Common issues and solutions"
4+
url: "https://mypy.readthedocs.io/en/stable/common_issues.html"
5+
- about: "Please ask and answer any questions on the mypy Gitter."
6+
name: "Questions or Chat"
7+
url: "https://gitter.im/python/typing"

.github/ISSUE_TEMPLATE/question.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
paths:
99
- 'docs/**'
10+
- 'mypyc/doc/**'
1011
- '**/*.rst'
1112
- '**/*.md'
1213
- CREDITS
@@ -21,9 +22,9 @@ jobs:
2122
- uses: actions/checkout@v2
2223
- uses: actions/setup-python@v2
2324
with:
24-
python-version: '3.7'
25+
python-version: '3.10'
2526
- name: Install tox
26-
run: pip install --upgrade 'setuptools!=50' 'virtualenv<16.7.11' tox==3.20.1
27+
run: pip install --upgrade 'setuptools!=50' 'virtualenv>=20.6.0' tox==3.24.5
2728
- name: Setup tox environment
2829
run: tox -e ${{ env.TOXENV }} --notest
2930
- name: Test

.github/workflows/mypy_primer.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
- '**/*.rst'
99
- '**/*.md'
1010
- 'mypyc/**'
11+
- 'mypy/stubtest.py'
12+
- 'mypy/stubgen.py'
13+
- 'mypy/stubgenc.py'
14+
- 'mypy/test/**'
1115

1216
jobs:
1317
mypy_primer:
@@ -26,7 +30,7 @@ jobs:
2630
fetch-depth: 0
2731
- uses: actions/setup-python@v2
2832
with:
29-
python-version: 3.8
33+
python-version: "3.10"
3034
- name: Install dependencies
3135
run: |
3236
python -m pip install -U pip
@@ -37,16 +41,19 @@ jobs:
3741
cd mypy_to_test
3842
echo "new commit"
3943
git rev-list --format=%s --max-count=1 $GITHUB_SHA
40-
git checkout -b upstream_master origin/master
44+
45+
MERGE_BASE=$(git merge-base $GITHUB_SHA origin/master)
46+
git checkout -b base_commit $MERGE_BASE
4147
echo "base commit"
42-
git rev-list --format=%s --max-count=1 upstream_master
48+
git rev-list --format=%s --max-count=1 base_commit
49+
4350
echo ''
4451
cd ..
4552
# fail action if exit code isn't zero or one
4653
(
4754
mypy_primer \
4855
--repo mypy_to_test \
49-
--new $GITHUB_SHA --old upstream_master \
56+
--new $GITHUB_SHA --old base_commit \
5057
--num-shards 3 --shard-index ${{ matrix.shard-index }} \
5158
--debug \
5259
--output concise \

.github/workflows/mypy_primer_comment.yml

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -38,62 +38,44 @@ jobs:
3838
fs.writeFileSync("diff.zip", Buffer.from(download.data));
3939
4040
- run: unzip diff.zip
41-
42-
# Based on https://github.com/kanga333/comment-hider
43-
- name: Hide old comments
44-
uses: actions/github-script@v3
45-
with:
46-
github-token: ${{secrets.GITHUB_TOKEN}}
47-
script: |
48-
const fs = require('fs')
49-
50-
const response = await github.issues.listComments({
51-
issue_number: fs.readFileSync("pr_number.txt", { encoding: "utf8" }),
52-
owner: context.repo.owner,
53-
repo: context.repo.repo,
54-
})
55-
const botCommentIds = response.data
56-
.filter(comment => comment.user.login === 'github-actions[bot]')
57-
.map(comment => comment.node_id)
58-
59-
for (const id of botCommentIds) {
60-
const resp = await github.graphql(`
61-
mutation {
62-
minimizeComment(input: {classifier: OUTDATED, subjectId: "${id}"}) {
63-
minimizedComment {
64-
isMinimized
65-
}
66-
}
67-
}
68-
`)
69-
if (resp.errors) {
70-
throw new Error(resp.errors)
71-
}
72-
}
41+
- run: |
42+
cat diff_*.txt | tee fulldiff.txt
7343
7444
- name: Post comment
45+
id: post-comment
7546
uses: actions/github-script@v3
7647
with:
77-
github-token: ${{secrets.GITHUB_TOKEN}}
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
7849
script: |
7950
const fs = require('fs')
80-
// Keep in sync with shards produced by mypy_primer workflow
81-
const data = (
82-
['diff_0.txt', 'diff_1.txt', 'diff_2.txt']
83-
.map(fileName => fs.readFileSync(fileName, { encoding: 'utf8' }))
84-
.join('')
85-
.substr(0, 30000) // About 300 lines
86-
)
51+
let data = fs.readFileSync('fulldiff.txt', { encoding: 'utf8' })
52+
// posting comment fails if too long, so truncate
53+
if (data.length > 30000) {
54+
data = data.substring(0, 30000) + `\n\n... (truncated ${data.length - 30000} chars) ...\n`
55+
}
8756
8857
console.log("Diff from mypy_primer:")
8958
console.log(data)
9059
60+
let body
9161
if (data.trim()) {
92-
const 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 + '```'
93-
await github.issues.createComment({
94-
issue_number: fs.readFileSync("pr_number.txt", { encoding: "utf8" }),
95-
owner: context.repo.owner,
96-
repo: context.repo.repo,
97-
body
98-
})
62+
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 + '```'
63+
} else {
64+
body = 'According to [mypy_primer](https://github.com/hauntsaninja/mypy_primer), this change has no effect on the checked open source code. 🤖🎉'
9965
}
66+
const prNumber = parseInt(fs.readFileSync("pr_number.txt", { encoding: "utf8" }))
67+
await github.issues.createComment({
68+
issue_number: prNumber,
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
body
72+
})
73+
return prNumber
74+
75+
- name: Hide old comments
76+
# v0.3.0
77+
uses: kanga333/comment-hider@bbdf5b562fbec24e6f60572d8f712017428b92e0
78+
with:
79+
github_token: ${{ secrets.GITHUB_TOKEN }}
80+
leave_visible: 1
81+
issue_number: ${{ steps.post-comment.outputs.result }}

.github/workflows/test.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
paths-ignore:
99
- 'docs/**'
10+
- 'mypyc/doc/**'
1011
- '**/*.rst'
1112
- '**/*.md'
1213
- .gitignore
@@ -75,11 +76,16 @@ jobs:
7576
toxenv: py36
7677
tox_extra_args: "-n 2 mypyc/test/test_run.py mypyc/test/test_external.py"
7778
debug_build: true
78-
- name: Type check our own code
79+
- name: Type check our own code (py37-ubuntu)
7980
python: '3.7'
8081
arch: x64
8182
os: ubuntu-latest
8283
toxenv: type
84+
- name: Type check our own code (py37-windows-64)
85+
python: '3.7'
86+
arch: x64
87+
os: windows-latest
88+
toxenv: type
8389
- name: Code style with flake8
8490
python: '3.7'
8591
arch: x64
@@ -102,7 +108,7 @@ jobs:
102108
./misc/build-debug-python.sh $PYTHONVERSION $PYTHONDIR $VENV
103109
source $VENV/bin/activate
104110
- name: Install tox
105-
run: pip install --upgrade 'setuptools!=50' 'virtualenv>=20.6.0' tox==3.20.1
111+
run: pip install --upgrade 'setuptools!=50' 'virtualenv>=20.6.0' tox==3.24.5
106112
- name: Compiled with mypyc
107113
if: ${{ matrix.test_mypyc }}
108114
run: |
@@ -113,24 +119,20 @@ jobs:
113119
- name: Test
114120
run: tox -e ${{ matrix.toxenv }} --skip-pkg-install -- ${{ matrix.tox_extra_args }}
115121

116-
# TODO: uncomment this when 3.11-dev is available
117-
# python-nightly:
118-
# runs-on: ubuntu-latest
119-
# name: Test suite with Python nightly
120-
# steps:
121-
# - uses: actions/checkout@v2
122-
# - uses: actions/setup-python@v2
123-
# with:
124-
# python-version: '3.11-dev'
125-
# - name: Install tox
126-
# run: |
127-
# pip install -U pip==21.2.3 setuptools
128-
# pip install --upgrade 'setuptools!=50' virtualenv==20.4.7 tox==3.20.1
129-
# - name: Setup tox environment
130-
# run: tox -e py --notest
131-
# - name: Test
132-
# run: tox -e py --skip-pkg-install -- "-n 2"
133-
# continue-on-error: true
134-
# - name: Mark as a success
135-
# run: exit 0
136-
122+
python-nightly:
123+
runs-on: ubuntu-latest
124+
name: Test suite with Python nightly
125+
steps:
126+
- uses: actions/checkout@v2
127+
- uses: actions/setup-python@v2
128+
with:
129+
python-version: '3.11-dev'
130+
- name: Install tox
131+
run: pip install --upgrade 'setuptools!=50' 'virtualenv>=20.6.0' tox==3.24.5
132+
- name: Setup tox environment
133+
run: tox -e py --notest
134+
- name: Test
135+
run: tox -e py --skip-pkg-install -- "-n 2"
136+
continue-on-error: true
137+
- name: Mark as a success
138+
run: exit 0

CONTRIBUTING.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ You can also use `tox` to run tests, for instance:
5454
tox -e py
5555
```
5656

57+
The easiest way to run a single test is:
58+
```
59+
pytest -n0 -k 'test_name'
60+
```
61+
There's more useful information on writing and running tests [here](test-data/unit/README.md)
62+
5763
## First time contributors
5864

5965
If you're looking for things to help with, browse our [issue tracker](https://github.com/python/mypy/issues)!
@@ -63,21 +69,24 @@ In particular, look for:
6369
- [good second issues](https://github.com/python/mypy/labels/good-second-issue)
6470
- [documentation issues](https://github.com/python/mypy/labels/documentation)
6571

66-
It's also extremely easy to get started contributing to our sister project
67-
[typeshed](https://github.com/python/typeshed/issues) that provides type stubs
68-
for libraries. This is a great way to become familiar with type syntax.
69-
70-
If you need help getting started, don't hesitate to ask on
71-
[gitter](https://gitter.im/python/typing).
72+
You do not need to ask for permission to work on any of these issues.
73+
Just fix the issue yourself, [try to add a unit test](#running-tests) and
74+
[open a pull request](#submitting-changes).
7275

7376
To get help fixing a specific issue, it's often best to comment on the issue
74-
itself. The more details you provide about what you've tried and where you've
75-
looked, the easier it will be for you to get help.
77+
itself. You're much more likely to get help if you provide details about what
78+
you've tried and where you've looked (maintainers tend to help those who help
79+
themselves). [gitter](https://gitter.im/python/typing) can also be a good place
80+
to ask for help.
7681

7782
Interactive debuggers like `pdb` and `ipdb` are really useful for getting
7883
started with the mypy codebase. This is a
7984
[useful tutorial](https://realpython.com/python-debugging-pdb/).
8085

86+
It's also extremely easy to get started contributing to our sister project
87+
[typeshed](https://github.com/python/typeshed/issues) that provides type stubs
88+
for libraries. This is a great way to become familiar with type syntax.
89+
8190
## Submitting changes
8291

8392
Even more excellent than a good bug report is a fix for a bug, or the

CREDITS

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ Dropbox core team:
1111

1212
Jukka Lehtosalo <[email protected]>
1313
Ivan Levkivskyi <[email protected]>
14+
Jared Hance
1415

1516
Non-Dropbox core team members:
1617

1718
Ethan Smith
1819
Guido van Rossum <[email protected]>
19-
Jelle Zijlstra
20+
Jelle Zijlstra <[email protected]>
2021
Michael J. Sullivan <[email protected]>
2122
Shantanu Jain
22-
Xuanda Yang
23+
Xuanda Yang <[email protected]>
24+
Jingchen Ye <[email protected]>
25+
Nikita Sobolev <[email protected]>
2326

2427
Past Dropbox core team members:
2528

LICENSE

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Mypy (and mypyc) are licensed under the terms of the MIT license, reproduced bel
44

55
The MIT License
66

7-
Copyright (c) 2015-2021 Jukka Lehtosalo and contributors
7+
Copyright (c) 2012-2022 Jukka Lehtosalo and contributors
8+
Copyright (c) 2015-2022 Dropbox, Inc.
89

910
Permission is hereby granted, free of charge, to any person obtaining a
1011
copy of this software and associated documentation files (the "Software"),
@@ -26,8 +27,8 @@ DEALINGS IN THE SOFTWARE.
2627

2728
= = = = =
2829

29-
Portions of mypy and mypyc are licensed under different licenses. The
30-
files under stdlib-samples as well as the files
30+
Portions of mypy and mypyc are licensed under different licenses.
31+
The files
3132
mypyc/lib-rt/pythonsupport.h, mypyc/lib-rt/getargs.c and
3233
mypyc/lib-rt/getargsfast.c are licensed under the PSF 2 License, reproduced
3334
below.

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ include runtests.py
4141
include pytest.ini
4242

4343
include LICENSE mypyc/README.md
44-
exclude .gitmodules CONTRIBUTING.md CREDITS ROADMAP.md tox.ini action.yml
44+
exclude .gitmodules CONTRIBUTING.md CREDITS ROADMAP.md tox.ini action.yml .editorconfig
4545

4646
global-exclude *.py[cod]
4747
global-exclude .DS_Store

0 commit comments

Comments
 (0)