Skip to content

Commit da5adc9

Browse files
committed
Merge remote-tracking branch 'origin/master' into paramspec
2 parents 442ecca + 965c6c9 commit da5adc9

File tree

836 files changed

+22161
-9025
lines changed

Some content is hidden

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

836 files changed

+22161
-9025
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
root = true
22

3-
[*.{py,c,cpp,h,rst,md,yml,json}]
3+
[*.{py,c,cpp,h,rst,md,yml,json,test}]
44
trim_trailing_whitespace = true
55
insert_final_newline = true
66
indent_style = space
77

8-
[*.{py,c,h,json}]
8+
[*.{py,c,h,json,test}]
99
indent_size = 4
1010

1111
[*.yml]

.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: 4 additions & 0 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:

.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: 8 additions & 2 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: |

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: 2 additions & 1 deletion
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"),

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Mypy: Static Typing for Python
44
=======================================
55

6+
[![Stable Version](https://img.shields.io/pypi/v/mypy?color=blue)](https://pypi.org/project/mypy/)
7+
[![Downloads](https://img.shields.io/pypi/dm/mypy)](https://pypistats.org/packages/mypy)
68
[![Build Status](https://api.travis-ci.com/python/mypy.svg?branch=master)](https://travis-ci.com/python/mypy)
79
[![Documentation Status](https://readthedocs.org/projects/mypy/badge/?version=latest)](https://mypy.readthedocs.io/en/latest/?badge=latest)
810
[![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)
@@ -63,7 +65,7 @@ Here is a small example to whet your appetite:
6365

6466
```python
6567
number = input("What is your favourite number?")
66-
print("Well, my favourite number is: ", number + 1) # error: Unsupported operand types for + ("str" and "int")
68+
print("It is", number + 1) # error: Unsupported operand types for + ("str" and "int")
6769
```
6870

6971
See [the documentation](https://mypy.readthedocs.io/en/stable/introduction.html) for more examples.
@@ -114,7 +116,7 @@ Mypy can be integrated into popular IDEs:
114116
* Sublime Text: [SublimeLinter-contrib-mypy](https://github.com/fredcallaway/SublimeLinter-contrib-mypy)
115117
* Atom: [linter-mypy](https://atom.io/packages/linter-mypy)
116118
* PyCharm: [mypy plugin](https://github.com/dropbox/mypy-PyCharm-plugin) (PyCharm integrates
117-
[its own implementation of PEP 484](https://www.jetbrains.com/help/pycharm/type-hinting-in-product.html))
119+
[its own implementation](https://www.jetbrains.com/help/pycharm/type-hinting-in-product.html) of [PEP 484](https://peps.python.org/pep-0484/))
118120
* VS Code: provides [basic integration](https://code.visualstudio.com/docs/python/linting#_mypy) with mypy.
119121
* pre-commit: use [pre-commit mirrors-mypy](https://github.com/pre-commit/mirrors-mypy).
120122

docs/requirements-docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sphinx>=4.2.0,<5.0.0
2-
sphinx-rtd-theme>=1.0.0,<2.0.0
2+
furo>=2022.3.4

docs/source/builtin_types.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Type Description
5353
``Iterable[int]`` iterable object containing ints
5454
``Sequence[bool]`` sequence of booleans (read-only)
5555
``Mapping[str, int]`` mapping from ``str`` keys to ``int`` values (read-only)
56+
``type[C]`` type object of ``C`` (``C`` is a class/type variable/union of types)
5657
====================== ===============================
5758

5859
The type ``dict`` is a *generic* class, signified by type arguments within
@@ -82,6 +83,7 @@ Type Description
8283
``Iterable[int]`` iterable object containing ints
8384
``Sequence[bool]`` sequence of booleans (read-only)
8485
``Mapping[str, int]`` mapping from ``str`` keys to ``int`` values (read-only)
86+
``Type[C]`` type object of ``C`` (``C`` is a class/type variable/union of types)
8587
====================== ===============================
8688

8789
``List`` is an alias for the built-in type ``list`` that supports

docs/source/cheat_sheet_py3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ Miscellaneous
296296
297297
import sys
298298
import re
299-
from typing import Match, AnyStr, IO
299+
from typing import Match, IO
300300
301301
# "typing.Match" describes regex matches from the re module
302302
x: Match[str] = re.match(r'[0-9]+', "15")

docs/source/common_issues.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ method signature. E.g.:
607607
608608
The third line elicits an error because mypy sees the argument type
609609
``bytes`` as a reference to the method by that name. Other than
610-
renaming the method, a work-around is to use an alias:
610+
renaming the method, a workaround is to use an alias:
611611

612612
.. code-block:: python
613613

docs/source/conf.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
master_doc = 'index'
4949

5050
# General information about the project.
51-
project = u'Mypy'
52-
copyright = u'2016, Jukka Lehtosalo'
51+
project = u'mypy'
52+
copyright = u'2012-2022 Jukka Lehtosalo and mypy contributors'
5353

5454
# The version info for the project you're documenting, acts as replacement for
5555
# |version| and |release|, also used in various other places throughout the
@@ -103,13 +103,7 @@
103103

104104
# The theme to use for HTML and HTML Help pages. See the documentation for
105105
# a list of builtin themes.
106-
try:
107-
import sphinx_rtd_theme
108-
except:
109-
html_theme = 'default'
110-
else:
111-
html_theme = 'sphinx_rtd_theme'
112-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
106+
html_theme = "furo"
113107

114108
# Theme options are theme-specific and customize the look and feel of a theme
115109
# further. For a list of options available for each theme, see the
@@ -128,7 +122,7 @@
128122

129123
# The name of an image file (relative to this directory) to place at the top
130124
# of the sidebar.
131-
#html_logo = None
125+
html_logo = "http://mypy-lang.org/static/mypy_light.svg"
132126

133127
# The name of an image file (within the static path) to use as favicon of the
134128
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
@@ -187,7 +181,7 @@
187181
#html_file_suffix = None
188182

189183
# Output file base name for HTML help builder.
190-
htmlhelp_basename = 'Mypydoc'
184+
htmlhelp_basename = 'mypydoc'
191185

192186

193187
# -- Options for LaTeX output ---------------------------------------------

0 commit comments

Comments
 (0)