Skip to content

Commit d49292d

Browse files
committed
Merge with mypy master
1 parent d730b8e commit d49292d

Some content is hidden

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

65 files changed

+1745
-9109
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ python:
1515

1616
install:
1717
- pip install -r test-requirements.txt
18+
- python2 -m pip install --user typing
1819
- python setup.py install
1920

2021
script:

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ DEALINGS IN THE SOFTWARE.
2727
= = = = =
2828

2929
Portions of mypy are licensed under different licenses. The files
30-
under stdlib-samples and lib-typing are licensed under the PSF 2
31-
License, reproduced below.
30+
under stdlib-samples are licensed under the PSF 2 License, reproduced below.
3231

3332
= = = = =
3433

ROADMAP.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Mypy Roadmap
2+
3+
The goal of the roadmap is to document areas the mypy core team is
4+
planning to work on in the future or is currently working on. PRs
5+
targeting these areas are very welcome, but please check first with a
6+
core team member that nobody else is working on the same thing.
7+
8+
**Note:** This doesn’t include everything that the core team will work
9+
on, and everything is subject to change. Near-term plans are likely
10+
more accurate.
11+
12+
## April-June 2017
13+
14+
- Add more comprehensive testing for `--incremental` and `--quick`
15+
modes to improve reliability. At least write more unit tests with
16+
focus on areas that have previously had bugs.
17+
([issue](https://github.com/python/mypy/issues/3455))
18+
19+
- Speed up `--quick` mode to better support million+ line codebases
20+
through some of these:
21+
22+
- Make it possible to use remote caching for incremental cache
23+
files. This would speed up a cold run with no local cache data.
24+
We need to update incremental cache to use hashes to determine
25+
whether files have changes to allow
26+
[sharing cache data](https://github.com/python/mypy/issues/3403).
27+
28+
- See if we can speed up deserialization of incremental cache
29+
files. Initial experiments aren’t very promising though so there
30+
might not be any easy wins left.
31+
([issue](https://github.com/python/mypy/issues/3456))
32+
33+
- Improve support for complex signatures such as `open(fn, 'rb')` and
34+
specific complex decorators such as `contextlib.contextmanager`
35+
through type checker plugins/hooks.
36+
([issue](https://github.com/python/mypy/issues/1240))
37+
38+
- Document basic properties of all type operations used within mypy,
39+
including compatibility, proper subtyping, joins and meets.
40+
([issue](https://github.com/python/mypy/issues/3454))
41+
42+
- Make TypedDict an officially supported mypy feature. This makes it
43+
possible to give precise types for dictionaries that represent JSON
44+
objects, such as `{"path": "/dir/fnam.ext", "size": 1234}`.
45+
([issue](https://github.com/python/mypy/issues/3453))
46+
47+
- Make error messages more useful and informative.
48+
([issue](https://github.com/python/mypy/labels/topic-usability))
49+
50+
- Resolve [#2008](https://github.com/python/mypy/issues/2008) (we are
51+
converging on approach 4).
52+
53+
## July-December 2017
54+
55+
- Invest some effort into systematically filling in missing
56+
annotations and stubs in typeshed, with focus on features heavily
57+
used at Dropbox. Better support for ORMs will be a separate
58+
project.
59+
60+
- Improve opt-in warnings about `Any` types to make it easier to keep
61+
code free from unwanted `Any` types. For example, warn about using
62+
`list` (instead of `List[x]`) and calling `open` if we can’t infer a
63+
precise return type, or using types imported from ignored modules
64+
(they are implicitly `Any`).
65+
66+
- Add support for protocols and structural subtyping (PEP 544).
67+
68+
- Switch completely to pytest and remove the custom testing framework.
69+
([issue](https://github.com/python/mypy/issues/1673))
70+
71+
- Make it possible to run mypy as a daemon to avoid reprocessing the
72+
entire program on each run. This will improve performance
73+
significantly. Even when using the incremental mode, processing a
74+
large number of files is not cheap.
75+
76+
- Refactor and simplify specific tricky parts of mypy internals, such
77+
as the [conditional type binder](https://github.com/python/mypy/issues/3457),
78+
[symbol tables](https://github.com/python/mypy/issues/3458) or
79+
the various [semantic analysis passes](https://github.com/python/mypy/issues/3459).
80+
81+
- Implement a general type system plugin architecture. It should be
82+
able to support some typical ORM features at least, such as
83+
metaclasses that add methods with automatically inferred signatures
84+
and complex descriptors such as those used by Django models.
85+
([issue](https://github.com/python/mypy/issues/1240))
86+
87+
- Add support for statically typed
88+
[protobufs](https://developers.google.com/protocol-buffers/).
89+
90+
- Provide much faster, reliable interactive feedback through
91+
fine-grained incremental type checking, built on top the daemon
92+
mode.
93+
94+
- Start work on editor plugins and support for selected IDE features.
95+
96+
- Turn on `--strict-optional` by default.

docs/source/cheat_sheet.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ When you're puzzled or when things are complicated
149149
reveal_type(c) # -> error: Revealed type is 'builtins.list[builtins.str]'
150150
print(c) # -> [4] the object is not cast
151151
152+
# if you want dynamic attributes on your class, have it override __setattr__ or __getattr__
153+
# in a stub or in your source code.
154+
# __setattr__ allows for dynamic assignment to names
155+
# __getattr__ allows for dynamic access to names
156+
class A:
157+
# this will allow assignment to any A.x, if x is the same type as `value`
158+
def __setattr__(self, name, value):
159+
# type: (str, int) -> None
160+
...
161+
a.foo = 42 # works
162+
a.bar = 'Ex-parrot' # fails type checking
163+
152164
# TODO: explain "Need type annotation for variable" when
153165
# initializing with None or an empty container
154166

docs/source/cheat_sheet_py3.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@ When you're puzzled or when things are complicated
142142
reveal_type(c) # -> error: Revealed type is 'builtins.list[builtins.str]'
143143
print(c) # -> [4] the object is not cast
144144
145+
# if you want dynamic attributes on your class, have it override __setattr__ or __getattr__
146+
# in a stub or in your source code.
147+
# __setattr__ allows for dynamic assignment to names
148+
# __getattr__ allows for dynamic access to names
149+
class A:
150+
# this will allow assignment to any A.x, if x is the same type as `value`
151+
def __setattr__(self, name: str, value: int) -> None: ...
152+
# this will allow access to any A.x, if x is compatible with the return type
153+
def __getattr__(self, name: str) -> int: ...
154+
a.foo = 42 # works
155+
a.bar = 'Ex-parrot' # fails type checking
156+
157+
145158
# TODO: explain "Need type annotation for variable" when
146159
# initializing with None or an empty container
147160

docs/source/common_issues.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ not support ``sort()``) as a list and sort it in-place:
180180
# Type of x is List[int] here.
181181
x.sort() # Okay!
182182
183-
.. _invariance-vs-covariance:
183+
.. _variance:
184184

185185
Invariance vs covariance
186186
------------------------

docs/source/config_file.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ overridden by the pattern sections matching the module name.
178178
- ``strict_boolean`` (Boolean, default False) makes using non-boolean
179179
expressions in conditions an error.
180180

181+
- ``no_implicit_optional`` (Boolean, default false) changes the treatment of
182+
arguments with a default value of None by not implicitly making their type Optional
181183

182184
Example
183185
*******

docs/source/revision_history.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ List of major changes:
3131

3232
* Add :ref:`variance-of-generics`.
3333

34-
* Add :ref:`invariance-vs-covariance`.
34+
* Add :ref:`variance`.
3535

3636
* Updates to :ref:`python-36`.
3737

extensions/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from distutils.core import setup
66

7-
version = '0.2.0'
7+
version = '0.3.0-dev'
88
description = 'Experimental type system extensions for programs checked with the mypy typechecker.'
99
long_description = '''
1010
Mypy Extensions

lib-typing/2.7/mod_generics_cache.py

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

lib-typing/2.7/setup.py

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

0 commit comments

Comments
 (0)