Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant fold more unary and binary expressions #14838

Closed
wants to merge 160 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
33bc95a
[mypyc] Constant fold str multiplication
ichard26 Mar 5, 2023
c80e95e
Refactor constant folding of binary ops
ichard26 Mar 5, 2023
ced8a10
Support constant folding complex ops
ichard26 Mar 5, 2023
54a892b
Support constant folding bytes ops
ichard26 Mar 5, 2023
c057484
Simplify irbuild.expression.set_literal_values()
ichard26 Mar 5, 2023
3b3c4c7
Support constant folding float ops
ichard26 Mar 5, 2023
3bae7d9
Also support folding complex with negative real
ichard26 Mar 5, 2023
3670d0d
Avoid constant folding in tests where it's unwanted + fix stub
ichard26 Mar 5, 2023
8d24649
Refactor to reduce repetition and improve consistency
ichard26 Mar 5, 2023
acde81b
Revert ParamSpec in functools.wraps on an ongoing basis (#14837)
hauntsaninja Mar 5, 2023
2ab1d82
CallableType.copy_modified: accept sequence for arg_names (#14840)
ikonst Mar 6, 2023
bbc9cce
Add signature for attr.evolve (#14526)
ikonst Mar 6, 2023
a5d03e2
Remove compatibility branches in test fixtures for dead Python versio…
AlexWaygood Mar 6, 2023
da6e4a0
stubinfo: remove two obsolete packages (#14842)
JelleZijlstra Mar 6, 2023
31f70d7
Fix narrow for walrus expressions used in match statements (#14844)
hauntsaninja Mar 6, 2023
b6cb0ed
Allow iterable class objects to be unpacked (including enums) (#14827)
AlexWaygood Mar 6, 2023
2523095
Some minor documentation tweaks (#14847)
JukkaL Mar 7, 2023
dfe0281
Remove unnecessary casts in `stubtest.py` and `types.py` (#14856)
AlexWaygood Mar 8, 2023
2e8dcbf
Support `if` statements in `dataclass` and `dataclass_transform` plug…
KRunchPL Mar 9, 2023
287c45a
Generate better reference information for member expressions (#14864)
JukkaL Mar 9, 2023
267d376
Update adopting strict docs for 1.0 (#14865)
hauntsaninja Mar 9, 2023
e45b53e
[mypyc] Add annotation in setup.py to avoid type ignore (#14874)
JukkaL Mar 11, 2023
32dd3c0
Remove unnecessary cast in `semanal_namedtuple.py` (#14875)
AlexWaygood Mar 11, 2023
106d57e
Add a helper function for narrowing `list[Expression]` to `list[StrEx…
AlexWaygood Mar 11, 2023
4b3722f
Improve the signatures of `expand_type` and `expand_type_by_instance`…
AlexWaygood Mar 11, 2023
fddd5c5
Use `assert`s instead of `cast`s where possible (#14860)
AlexWaygood Mar 11, 2023
3098574
Add error code to typing_extensions suggestion (#14881)
hauntsaninja Mar 11, 2023
fb6b8bc
Allow SupportsIndex in slice expressions (#14738)
hauntsaninja Mar 11, 2023
e2e5d7f
Fix incompatible overrides of overloaded generics with self types (#1…
hauntsaninja Mar 11, 2023
70d4bb2
Fix selfcheck with the latest version of `types-typed-ast` (#14883)
AlexWaygood Mar 12, 2023
4365dad
Fix crash on ParamSpec in incremental mode (#14885)
ilevkivskyi Mar 12, 2023
895a821
Fix line number if __iter__ is incorrectly reported as missing (#14893)
JukkaL Mar 13, 2023
486a51b
Fix misleading TODO comment in `testIterableUnpackingWithGetAttr` (#1…
AlexWaygood Mar 13, 2023
d05974b
[mypyc] Use a native unboxed representation for floats (#14880)
JukkaL Mar 14, 2023
730ba8a
Don't duplicate ParamSpec prefixes and properly substitute Paramspecs…
A5rocks Mar 15, 2023
9cb4872
Handle type[TypeVar] (#14756)
sterliakov Mar 15, 2023
85dac76
Sync typeshed
AlexWaygood Mar 15, 2023
250e6fd
Remove use of LiteralString in builtins (#13743)
hauntsaninja Sep 26, 2022
a633a72
Revert sum literal integer change (#13961)
hauntsaninja Oct 29, 2022
1ceeb1f
Revert typeshed ctypes change (#14128)
hauntsaninja Nov 18, 2022
e1a82a2
Revert use of `ParamSpec` for `functools.wraps`
AlexWaygood Mar 4, 2023
fed798a
Fix tests
AlexWaygood Mar 15, 2023
8d59d31
Update commit hashes in `sync-typeshed.py` following latest typeshed …
AlexWaygood Mar 15, 2023
a6b5b1e
[dataclass_transform] fix frozen behavior for base classes with direc…
wesleywright Mar 15, 2023
59886d2
Add better error checking to misc/convert-cache.py (#14909)
JukkaL Mar 16, 2023
fccaab0
Fix crash on single item union of alias (#14876)
ilevkivskyi Mar 18, 2023
e07ccde
[stubtest] Respect `@final` runtime decorator, enforce it in stubs (#…
sobolevn Mar 19, 2023
4a54894
Fix crash on class-level import in protocol definition (#14926)
ilevkivskyi Mar 20, 2023
1a8ea61
[mypyc] Avoid boxing/unboxing when coercing between tuple types (#14899)
JukkaL Mar 20, 2023
9944d5f
[mypyc] Support iterating over a TypedDict (#14747)
ichard26 Mar 20, 2023
aa2679b
[mypyc] Fixes to float to int conversion (#14936)
JukkaL Mar 22, 2023
4e6d683
[mypyc] Document native floats and integers (#14927)
JukkaL Mar 22, 2023
bfa9eac
[mypyc] Be stricter about function prototypes (#14942)
JukkaL Mar 23, 2023
764ff6f
Bump version to 1.3.0+dev (#14948)
JukkaL Mar 23, 2023
2c6e43e
Stubtest: check that the stub is abstract if the runtime is, even whe…
AlexWaygood Mar 24, 2023
01a088b
Stubtest: verify stub methods or properties are decorated with `@fina…
AlexWaygood Mar 24, 2023
354641f
[dataclass_transform] fix deserialization for frozen_default
wesleywright Mar 25, 2023
c29c173
better testcase name
wesleywright Mar 25, 2023
802b947
explanatory comment
wesleywright Mar 25, 2023
6a43e73
Fix typo in stubtest docs (#14947)
aminalaee Mar 25, 2023
1dd26a3
Multiple inheritance considers callable objects as subtypes of functi…
tyralla Mar 25, 2023
46ab0f8
Simplify `len()` comparisons (#14907)
dosisod Mar 25, 2023
c5ddc36
Fix narrowing union types that include Self with isinstance (#14923)
tyralla Mar 25, 2023
5c459d2
[minor] sort tox testenvs to ease finding one (#14904)
yarikoptic Mar 25, 2023
11c2c6d
Fix test-data diffs not to produce traceback (#14549)
ikonst Mar 25, 2023
3f35ebb
Add support for converters with TypeVars on generic attrs classes (#1…
chadrik Mar 25, 2023
c170056
Check typeguard validity for staticmethods (#14953)
A5rocks Mar 26, 2023
c517b86
Check for duplicated files in tests (#14960)
A5rocks Mar 26, 2023
2e75cba
Make some stubtest tests less verbose (#14961)
AlexWaygood Mar 26, 2023
ddf0c05
Improve bytes formatting error (#14959)
hauntsaninja Mar 29, 2023
7c49fa6
Improve async documentation (#14973)
hauntsaninja Mar 30, 2023
10ae912
Improvements to cheat sheet (#14972)
hauntsaninja Mar 30, 2023
a9a047e
Add documentation for bytes formatting error code (#14971)
hauntsaninja Mar 30, 2023
da7268c
Convert insecure links to use HTTPS (#14974)
intgr Mar 30, 2023
25c0631
Modernize stubgen
sobolevn Mar 30, 2023
89469ac
Fix CI
sobolevn Mar 30, 2023
5a57764
Sync typeshed
AlexWaygood Apr 1, 2023
ac65631
Remove use of LiteralString in builtins (#13743)
hauntsaninja Sep 26, 2022
d8674f3
Revert sum literal integer change (#13961)
hauntsaninja Oct 29, 2022
e437cdf
Revert typeshed ctypes change (#14128)
hauntsaninja Nov 18, 2022
e85f54e
Revert use of `ParamSpec` for `functools.wraps`
AlexWaygood Mar 4, 2023
a44afe1
Update commit hashes in `misc/sync-typeshed.py` following typeshed sy…
AlexWaygood Apr 1, 2023
7d2844c
Also mention overloads in async iterator documentation (#14998)
hauntsaninja Apr 3, 2023
bf82b76
Fix stubtest false positives with TypedDicts at runtime (#14984)
AlexWaygood Apr 4, 2023
16bd311
Support descriptors in dataclass transform (#15006)
JukkaL Apr 5, 2023
0f09be4
[dataclass_transform] support implicit default for "init" parameter i…
JukkaL Apr 5, 2023
e21ddbf
stubtest: improve allowlist documentation (#15008)
hauntsaninja Apr 5, 2023
a9ee618
Fix disappearing errors when re-running dmypy check (#14835)
meshy Apr 9, 2023
d328c22
Clarify "Using types...but not at runtime" docs (#15029)
jonshea Apr 11, 2023
b43e0d3
Add negative subtype caches (#14884)
ilevkivskyi Apr 11, 2023
cc7b062
Fix attrs.evolve on bound TypeVar (#15022)
ikonst Apr 12, 2023
5005428
Fix alignment of cheat sheet example (#15039)
vallpaper Apr 12, 2023
11166b7
[stubgen] Add `@functools.cached_property` support (#14981)
sobolevn Apr 14, 2023
1a47b19
Fix error for callback protocol matching against callable type object…
hauntsaninja Apr 14, 2023
8f94d9a
Improvements to stubgenc (#14564)
chadrik Apr 15, 2023
69c774e
Sync typeshed (#15055)
github-actions[bot] Apr 15, 2023
1449366
Allow objects matching `SupportsKeysAndGetItem` to be unpacked (#14990)
bryanforbes Apr 15, 2023
4276308
(🎁) update black to 23.3.0 (#15059)
KotlinIsland Apr 15, 2023
0799a8a
[mypyc] Fix unions of bools and ints (#15066)
r3m0t Apr 17, 2023
3d9661c
Fix bounded self types in override incompatibility checking (#15045)
hauntsaninja Apr 18, 2023
768ba66
Make messages use builtin types instead of typing's types (#15070)
koogoro Apr 19, 2023
0845818
Bump version to 1.4 in preparation for 1.3 release (#15077)
wesleywright Apr 19, 2023
2a4c473
attrs.evolve: support generics and unions (#15050)
ikonst Apr 21, 2023
3cca987
Regression test for make_simplified_union truthiness (#15098)
hauntsaninja Apr 21, 2023
bd6ce23
Fix performance in union subtyping (#15104)
hauntsaninja Apr 23, 2023
315b466
Use dict keys for order-preserving dedupes instead of set + list (#15…
adriangb Apr 23, 2023
31708f3
Fix sys.platform when cross-compiling with emscripten (#14888)
emmatyping Apr 24, 2023
0061d6e
Allow narrowing enum values using == (#11521)
hauntsaninja Apr 24, 2023
7be0d4b
Fix black (#15112)
hauntsaninja Apr 24, 2023
186432d
Replace `x[:]` with `x.copy()` (#14949)
dosisod Apr 24, 2023
bdac4bc
Fix nested async functions when using TypeVar value restriction (#14705)
JukkaL Apr 24, 2023
aee983e
Don't type check most function bodies if ignoring errors (#14150)
JukkaL Apr 24, 2023
ba35026
[mypyc] Switch to table-driven imports for smaller IR (#14917)
ichard26 Apr 24, 2023
a2b0f18
Fix pyinfo for Python 3.12 changes (#15103)
hauntsaninja Apr 24, 2023
9ce3470
Migrate fastparse to use ErrorMessage class (#14753)
tusharsadhwani Apr 24, 2023
fe8873f
Generates error when staticmethod and classmethod decorators are both…
Apr 24, 2023
334daca
Use X | Y union syntax in error messages (#15102)
omarsilva1 Apr 24, 2023
15fbd53
Add tests for language changes in 3.11 (#15120)
eevelweezel Apr 25, 2023
00f3913
Documentation Update to CONTRIBUTING.md (#15130)
ajrpeggio Apr 25, 2023
97e7f3e
Don't run flake8 twice in CI (#15129)
AlexWaygood Apr 25, 2023
e4217f2
Update message about invalid exception type in try (#15131)
ajrpeggio Apr 25, 2023
0dafc47
15110: set env var for subprocess, check version in script (#15122)
eevelweezel Apr 25, 2023
0c6e18a
Add explanation if argument type is incompatible because of a "number…
JukkaL Apr 26, 2023
bd2a641
Set soft error limit default to -1 (unlimited) (#15138)
rohitsanj Apr 26, 2023
6b326d5
Fix assert_type behaviour with Instance last_known_value (#15123)
CarlFK Apr 26, 2023
16b936c
Rename attrs tests (#15124)
ikonst Apr 26, 2023
bf6b21d
Use `type` instead of `Type` in errors on newer Python (#15139)
rohitsanj Apr 26, 2023
09d469f
Make stubgen respect MYPY_CACHE_DIR (#14722)
jhbaarnh Apr 26, 2023
9cead12
Improve README formatting (#15143)
ajrpeggio Apr 26, 2023
b5914b5
Simplify `isinstance` calls (#15149)
dosisod Apr 27, 2023
29cc561
Improve mypy_primer comment (#15144)
hauntsaninja Apr 28, 2023
6b1fc86
Fix syntax error in mypy primer comment (#15156)
hauntsaninja Apr 29, 2023
3097169
Fix a crash when function-scope recursive alias appears as upper boun…
ilevkivskyi May 1, 2023
dbb72bb
Clarify usage of callables regarding type object in docs (#15079)
Viicos May 1, 2023
8b356ff
Sync typeshed
AlexWaygood May 1, 2023
c844270
Remove use of LiteralString in builtins (#13743)
hauntsaninja Sep 26, 2022
9ebe5fd
Revert sum literal integer change (#13961)
hauntsaninja Oct 29, 2022
d198719
Revert typeshed ctypes change
AlexWaygood May 1, 2023
b1761f4
Revert use of `ParamSpec` for `functools.wraps`
AlexWaygood Mar 4, 2023
17b4693
Fix ctypes plugin (hopefully)
AlexWaygood May 1, 2023
6f28cc3
Update hashes in `misc/sync-typeshed.py` following typeshed sync (#15…
AlexWaygood May 1, 2023
9f69bea
Fix crash on lambda in generic context with generic method in body (#…
ilevkivskyi May 2, 2023
b5107a9
Fix crash in dataclass protocol with self attribute assignment (#15157)
ilevkivskyi May 2, 2023
66602fc
Fix spurious errors on builtins.open (#15161)
hauntsaninja May 2, 2023
61f6358
Do not show unused-ignore errors in unreachable code, and make it a r…
ilevkivskyi May 2, 2023
d71ece8
[pre-commit.ci] pre-commit autoupdate (#15167)
pre-commit-ci[bot] May 2, 2023
8c14cba
Propagate type narrowing to nested functions (#15133)
JukkaL May 3, 2023
61b9b9c
[PEP646] Add tests/fixes for callable star args behavior (#15069)
jhance May 3, 2023
d17b3ed
Revert "Fix disappearing errors when re-running dmypy check (#14835)"…
JukkaL May 4, 2023
13f35ad
Fix crash related to propagating type narrowing to nested functions (…
JukkaL May 4, 2023
a8bd273
Output distinct types when type names are ambiguous (#15184)
teresa0605 May 4, 2023
fea5c93
Simplify iterator usage (#15185)
dosisod May 4, 2023
541639e
Make dict expression inference more consistent (#15174)
ilevkivskyi May 5, 2023
d710fdd
stubgen: Support TypedDict alternative syntax (#14682)
hamdanal May 6, 2023
171e6f8
stubgen: Fix call-based namedtuple omitted from class bases (#14680)
hamdanal May 6, 2023
b69060a
Synchronize test-requirements.txt and .pre-commit-config.yaml (#15197)
hamdanal May 6, 2023
0655190
Merge branch 'improved-constant-folding' into improved-constant-foldi…
ichard26 May 6, 2023
85a35c4
Fixup IR tests after native floats landed
ichard26 May 6, 2023
7fb8f8c
Moar comments
ichard26 May 6, 2023
7542d99
Fix typo in IRbuild test + remove unused import
ichard26 May 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/mypy_primer_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
if (data.trim()) {
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 + '```'
} else {
body = 'According to [mypy_primer](https://github.com/hauntsaninja/mypy_primer), this change has no effect on the checked open source code. 🤖🎉'
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. ✅"
}
const prNumber = parseInt(fs.readFileSync("pr_number.txt", { encoding: "utf8" }))
await github.rest.issues.createComment({
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ jobs:
arch: x64
os: windows-latest
toxenv: type
# We also run these checks with pre-commit in CI,
# but it's useful to run them with tox too,
# to ensure the tox env works as expected
- name: Formatting with Black + isort and code style with flake8
python: '3.7'
arch: x64
Expand Down
10 changes: 7 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
repos:
- repo: https://github.com/psf/black
rev: 22.12.0 # must match test-requirements.txt
rev: 23.3.0 # must match test-requirements.txt
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.11.5 # must match test-requirements.txt
rev: 5.11.5 # must match test-requirements.txt (cannot use version 5.12 until python 3.7 support is dropped)
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 5.0.4 # must match test-requirements.txt
rev: 5.0.4 # must match test-requirements.txt (cannot use version 6 until python 3.7 support is dropped)
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==22.12.6 # must match test-requirements.txt
- flake8-noqa==1.3.0 # must match test-requirements.txt

ci:
# We run flake8 as part of our GitHub Actions suite in CI
skip: [flake8]
55 changes: 32 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,33 @@ issue tracker, pull requests, and chat, is expected to treat
other people with respect and more generally to follow the guidelines
articulated in the [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/).


## Getting started with development

### Setup

#### (1) Clone the mypy repository and enter into it
```
git clone https://github.com/python/mypy.git
#### (1) Fork the mypy repository

Within Github, navigate to <https://github.com/python/mypy> and fork the repository.

#### (2) Clone the mypy repository and enter into it

```bash
git clone [email protected]:<your_username>/mypy.git
cd mypy
```

#### (2) Create then activate a virtual environment
```
#### (3) Create then activate a virtual environment

```bash
# On Windows, the commands may be slightly different. For more details, see
# https://docs.python.org/3/library/venv.html#creating-virtual-environments
python3 -m venv venv
source venv/bin/activate
```

#### (3) Install the test requirements and the project
```
#### (4) Install the test requirements and the project

```bash
python3 -m pip install -r test-requirements.txt
python3 -m pip install -e .
hash -r # This resets shell PATH cache, not necessary on Windows
Expand All @@ -47,12 +53,14 @@ your PR.

However, if you wish to do so, you can run the full test suite
like this:
```

```bash
python3 runtests.py
```

You can also use `tox` to run tests (`tox` handles setting up the test environment for you):
```

```bash
tox run -e py

# Or some specific python version:
Expand All @@ -63,6 +71,7 @@ tox run -e lint
```

Some useful commands for running specific tests include:

```bash
# Use mypy to check mypy's own code
python3 runtests.py self
Expand Down Expand Up @@ -90,6 +99,7 @@ see [the README in the test-data directory](test-data/unit/README.md).
If you're looking for things to help with, browse our [issue tracker](https://github.com/python/mypy/issues)!

In particular, look for:

- [good first issues](https://github.com/python/mypy/labels/good-first-issue)
- [good second issues](https://github.com/python/mypy/labels/good-second-issue)
- [documentation issues](https://github.com/python/mypy/labels/documentation)
Expand Down Expand Up @@ -151,28 +161,27 @@ You may also find other pages in the
[Mypy developer guide](https://github.com/python/mypy/wiki/Developer-Guides)
helpful in developing your change.


## Core developer guidelines

Core developers should follow these rules when processing pull requests:

* Always wait for tests to pass before merging PRs.
* Use "[Squash and merge](https://github.com/blog/2141-squash-your-commits)"
- Always wait for tests to pass before merging PRs.
- Use "[Squash and merge](https://github.com/blog/2141-squash-your-commits)"
to merge PRs.
* Delete branches for merged PRs (by core devs pushing to the main repo).
* Edit the final commit message before merging to conform to the following
- Delete branches for merged PRs (by core devs pushing to the main repo).
- Edit the final commit message before merging to conform to the following
style (we wish to have a clean `git log` output):
* When merging a multi-commit PR make sure that the commit message doesn't
- When merging a multi-commit PR make sure that the commit message doesn't
contain the local history from the committer and the review history from
the PR. Edit the message to only describe the end state of the PR.
* Make sure there is a *single* newline at the end of the commit message.
- Make sure there is a *single* newline at the end of the commit message.
This way there is a single empty line between commits in `git log`
output.
* Split lines as needed so that the maximum line length of the commit
- Split lines as needed so that the maximum line length of the commit
message is under 80 characters, including the subject line.
* Capitalize the subject and each paragraph.
* Make sure that the subject of the commit message has no trailing dot.
* Use the imperative mood in the subject line (e.g. "Fix typo in README").
* If the PR fixes an issue, make sure something like "Fixes #xxx." occurs
- Capitalize the subject and each paragraph.
- Make sure that the subject of the commit message has no trailing dot.
- Use the imperative mood in the subject line (e.g. "Fix typo in README").
- If the PR fixes an issue, make sure something like "Fixes #xxx." occurs
in the body of the message (not in the subject).
* Use Markdown for formatting.
- Use Markdown for formatting.
62 changes: 36 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ To report a bug or request an enhancement:
tracker for that library

To discuss a new type system feature:

- discuss at [typing-sig mailing list](https://mail.python.org/archives/list/[email protected]/)
- there is also some historical discussion [here](https://github.com/python/typing/issues)


What is mypy?
-------------

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

In particular, see:

- [type hints cheat sheet](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html)
- [getting started](https://mypy.readthedocs.io/en/stable/getting_started.html)
- [list of error codes](https://mypy.readthedocs.io/en/stable/error_code_list.html)
Expand All @@ -91,67 +92,75 @@ Quick start

Mypy can be installed using pip:

python3 -m pip install -U mypy
```bash
python3 -m pip install -U mypy
```

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

python3 -m pip install -U git+https://github.com/python/mypy.git
# or if you don't have 'git' installed
python3 -m pip install -U https://github.com/python/mypy/zipball/master
```bash
python3 -m pip install -U git+https://github.com/python/mypy.git
# or if you don't have 'git' installed
python3 -m pip install -U https://github.com/python/mypy/zipball/master
```

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

mypy PROGRAM
```bash
mypy PROGRAM
```

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

python3 PROGRAM
```bash
python3 PROGRAM
```

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

dmypy run -- PROGRAM
```bash
dmypy run -- PROGRAM
```

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


Integrations
------------

Mypy can be integrated into popular IDEs:

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

Web site and documentation
--------------------------

Additional information is available at the web site:

http://www.mypy-lang.org/
<https://www.mypy-lang.org/>

Jump straight to the documentation:

https://mypy.readthedocs.io/
<https://mypy.readthedocs.io/>

Follow along our changelog at:

https://mypy-lang.blogspot.com/

<https://mypy-lang.blogspot.com/>

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

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


Mypyc and compiled version of mypy
----------------------------------

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

To install an interpreted mypy instead, use:

python3 -m pip install --no-binary mypy -U mypy
```bash
python3 -m pip install --no-binary mypy -U mypy
```

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

To contribute to the mypyc project, check out https://github.com/mypyc/mypyc
To contribute to the mypyc project, check out <https://github.com/mypyc/mypyc>
2 changes: 1 addition & 1 deletion build-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
-r mypy-requirements.txt
types-psutil
types-setuptools
types-typed-ast>=1.5.8,<1.6.0
types-typed-ast>=1.5.8.5,<1.6.0
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def pytest_configure(config):


# This function name is special to pytest. See
# http://doc.pytest.org/en/latest/writing_plugins.html#initialization-command-line-and-configuration-hooks
# https://doc.pytest.org/en/latest/how-to/writing_plugins.html#initialization-command-line-and-configuration-hooks
def pytest_addoption(parser) -> None:
parser.addoption(
"--bench", action="store_true", default=False, help="Enable the benchmark test runs"
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ BUILDDIR = build

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from https://www.sphinx-doc.org/)
endif

# Internal variables.
Expand Down
2 changes: 1 addition & 1 deletion docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if errorlevel 9009 (
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
echo.https://www.sphinx-doc.org/
exit /b 1
)

Expand Down
2 changes: 1 addition & 1 deletion docs/source/additional_features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Caveats/Known Issues
:py:meth:`__init__ <object.__init__>` will be replaced by ``Any``.

* :ref:`Validator decorators <attrs:examples-validators>`
and `default decorators <http://www.attrs.org/en/stable/examples.html#defaults>`_
and `default decorators <https://www.attrs.org/en/stable/examples.html#defaults>`_
are not type-checked against the attribute they are setting/validating.

* Method definitions added by mypy currently overwrite any existing method
Expand Down
Loading