Skip to content

Commit a6c5089

Browse files
committed
Merge from upstream/master
2 parents 2281a86 + 125ef0d commit a6c5089

File tree

248 files changed

+75059
-1424
lines changed

Some content is hidden

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

248 files changed

+75059
-1424
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,12 @@ include/
4343

4444
.tox
4545
pip-wheel-metadata
46+
47+
48+
test_capi
49+
*.o
50+
*.a
51+
test_capi
52+
/.mypyc-flake8-cache.json
53+
/mypyc/lib-rt/build/
54+
/mypyc/lib-rt/*.so

.travis.yml

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@ if: tag IS present OR type = pull_request OR ((branch = master OR branch =~ rele
44
language: python
55
# cache package wheels (1 cache per python version)
66
cache: pip
7+
# also cache the directories where we set up our custom pythons in some builds
8+
cache:
9+
directories:
10+
- $HOME/python-debug
11+
# I ran into some issues with this but will investigate again later.
12+
# - $HOME/.pyenv/versions
13+
- $HOME/Library/Caches/pip
14+
715
# newer python versions are available only on xenial (while some older only on trusty) Ubuntu distribution
816
dist: xenial
917

1018
env:
1119
TOXENV=py
1220
EXTRA_ARGS="-n 12"
1321
TEST_MYPYC=0
22+
PYTHON_DEBUG_BUILD=0
1423

1524
jobs:
1625
include:
@@ -22,14 +31,28 @@ jobs:
2231
python: 3.6 # 3.6.3 pip 9.0.1
2332
- name: "run test suite with python 3.7"
2433
python: 3.7 # 3.7.0 pip 10.0.1
34+
- name: "run test suite with python 3.8-dev"
35+
python: 3.8-dev
36+
- name: "run mypyc runtime tests with python 3.6 debug build"
37+
language: generic
38+
env:
39+
- TOXENV=py36
40+
- PYTHONVERSION=3.6.8
41+
- PYTHON_DEBUG_BUILD=1
42+
- EXTRA_ARGS="-n 12 mypyc/test/test_run.py mypyc/test/test_external.py"
43+
- name: "run mypyc runtime tests with python 3.6 on OS X"
44+
os: osx
45+
osx_image: xcode8.3
46+
language: generic
47+
env:
48+
- PYTHONVERSION=3.6.3
49+
- EXTRA_ARGS="-n 12 mypyc/test/test_run.py mypyc/test/test_external.py"
2550
- name: "run test suite with python 3.7 (compiled with mypyc)"
2651
python: 3.7
2752
env:
2853
- TOXENV=py
2954
- EXTRA_ARGS="-n 12"
3055
- TEST_MYPYC=1
31-
# - name: "run test suite with python 3.8-dev"
32-
# python: 3.8-dev
3356
- name: "type check our own code"
3457
python: 3.7
3558
env:
@@ -58,11 +81,33 @@ install:
5881
- pip install -U pip setuptools
5982
- pip install -U tox==3.9.0
6083
- tox --notest
84+
6185
# This is a big hack and only works because the layout of our directories
6286
# means that tox picks up the mypy from the source directories instead of
6387
# the version it installed into a venv. This is also *why* we need to do this,
6488
# since if we arranged for tox to build with mypyc, pytest wouldn't use it.
65-
- if [[ $TEST_MYPYC == 1 ]]; then pip install -r mypyc-requirements.txt; CC=clang MYPYC_OPT_LEVEL=0 python3 setup.py --use-mypyc build_ext --inplace; fi
89+
- if [[ $TEST_MYPYC == 1 ]]; then pip install -r mypy-requirements.txt; CC=clang MYPYC_OPT_LEVEL=0 python3 setup.py --use-mypyc build_ext --inplace; fi
6690

6791
script:
6892
- tox -- $EXTRA_ARGS
93+
94+
# Getting our hands on a debug build or the right OS X build is
95+
# annoying, unfortunately.
96+
before_install: |
97+
set -e
98+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
99+
if [[ $PYTHON_DEBUG_BUILD == 1 ]]; then
100+
PYTHONDIR=~/python-debug/python-$PYTHONVERSION
101+
VENV=$PYTHONDIR/env
102+
misc/build-debug-python.sh $PYTHONVERSION $PYTHONDIR $VENV
103+
source $VENV/bin/activate
104+
fi
105+
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
106+
# Attempt to install, skipping if version already exists.
107+
pyenv install $PYTHONVERSION -s
108+
# Regenerate shims
109+
pyenv rehash
110+
# Manually set pyenv variables per https://pythonhosted.org/CodeChat/.travis.yml.html
111+
export PYENV_VERSION=$PYTHONVERSION
112+
export PATH="/Users/travis/.pyenv/shims:${PATH}"
113+
fi

LICENSE

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Mypy is licensed under the terms of the MIT license, reproduced below.
1+
Mypy (and mypyc) are licensed under the terms of the MIT license, reproduced below.
22

33
= = = = =
44

55
The MIT License
66

7-
Copyright (c) 2015-2016 Jukka Lehtosalo and contributors
7+
Copyright (c) 2015-2019 Jukka Lehtosalo and contributors
88

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

2727
= = = = =
2828

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

3234
= = = = =
3335

@@ -223,5 +225,3 @@ FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
223225
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
224226
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
225227
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
226-
227-
= = = = =

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,10 @@ Compiled version of mypy
265265
------------------------
266266

267267
We have built an compiled version of mypy using the [mypyc
268-
compiler](https://github.com/mypyc/mypyc) for mypy-annotated Python
269-
code. It is approximately 4 times faster than interpreted mypy and is
270-
available (and the default) for 64-bit Windows, macOS, and Linux.
268+
compiler](https://github.com/python/mypy/tree/master/mypyc) for
269+
mypy-annotated Python code. It is approximately 4 times faster than
270+
interpreted mypy and is available (and the default) for 64-bit
271+
Windows, macOS, and Linux.
271272

272273
To install an interpreted mypy instead, use:
273274

appveyor.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ cache:
33

44
environment:
55
matrix:
6-
76
- PYTHON: "C:\\Python37-x64"
87
PYTHON_VERSION: "3.7.x"
98
PYTHON_ARCH: "64"
9+
EXTRA_ARGS:
10+
- PYTHON: "C:\\Python37"
11+
PYTHON_VERSION: "3.7.x"
12+
PYTHON_ARCH: "32"
13+
EXTRA_ARGS: "mypyc/test/test_run.py mypyc/test/test_external.py"
1014

1115
install:
1216
- "git submodule update --init mypy/typeshed"
@@ -16,7 +20,7 @@ install:
1620
build: off
1721

1822
test_script:
19-
- "%PYTHON%\\python.exe -m tox -e py37"
23+
- "%PYTHON%\\python.exe -m tox -e py37 %EXTRA_ARGS%"
2024

2125
skip_commits:
2226
files:

conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ def pytest_configure(config):
99
mypy_source_root = os.path.dirname(os.path.abspath(__file__))
1010
if os.getcwd() != mypy_source_root:
1111
os.chdir(mypy_source_root)
12+
13+
14+
# This function name is special to pytest. See
15+
# http://doc.pytest.org/en/latest/writing_plugins.html#initialization-command-line-and-configuration-hooks
16+
def pytest_addoption(parser) -> None:
17+
parser.addoption('--bench', action='store_true', default=False,
18+
help='Enable the benchmark test runs')

docs/source/command_line.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,18 @@ of the above sections.
429429
``--no-implicit-reexport``
430430
By default, imported values to a module are treated as exported and mypy allows
431431
other modules to import them. This flag changes the behavior to not re-export unless
432-
the item is imported using from-as. Note this is always treated as enabled for
433-
stub files. For example:
432+
the item is imported using from-as or is included in ``__all__``. Note this is
433+
always treated as enabled for stub files. For example:
434434

435435
.. code-block:: python
436436
437437
# This won't re-export the value
438438
from foo import bar
439439
# This will re-export it as bar and allow other modules to import it
440440
from foo import bar as bar
441+
# This will also re-export bar
442+
from foo import bar
443+
__all__ = ['bar']
441444
442445
443446
``--strict-equality``
@@ -500,6 +503,13 @@ in error messages.
500503

501504
main.py:12:9: error: Unsupported operand types for / ("int" and "str")
502505

506+
``--no-color-output``
507+
This flag will disable color output in error messages, enabled by default.
508+
509+
``--no-error-summary``
510+
This flag will disable error summary. By default mypy shows a summary line
511+
including total number of errors, number of files with errors, and number
512+
of files checked.
503513

504514
.. _incremental:
505515

@@ -530,6 +540,9 @@ beyond what incremental mode can offer, try running mypy in
530540
change this folder. This flag can also be useful for controlling
531541
cache use when using :ref:`remote caching <remote-cache>`.
532542

543+
This setting will override the ``MYPY_CACHE_DIR`` environment
544+
variable if it is set.
545+
533546
Mypy will also always write to the cache even when incremental
534547
mode is disabled so it can "warm up" the cache. To disable
535548
writing to the cache, use ``--cache-dir=/dev/null`` (UNIX)

docs/source/config_file.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,18 @@ Miscellaneous strictness flags
310310
``implicit_reexport`` (bool, default True)
311311
By default, imported values to a module are treated as exported and mypy allows
312312
other modules to import them. When false, mypy will not re-export unless
313-
the item is imported using from-as. Note that mypy treats stub files as if this
314-
is always disabled. For example:
313+
the item is imported using from-as or is included in ``__all__``. Note that mypy
314+
treats stub files as if this is always disabled. For example:
315315

316316
.. code-block:: python
317317
318318
# This won't re-export the value
319319
from foo import bar
320320
# This will re-export it as bar and allow other modules to import it
321321
from foo import bar as bar
322+
# This will also re-export bar
323+
from foo import bar
324+
__all__ = ['bar']
322325
323326
``strict_equality`` (bool, default False)
324327
Prohibit equality checks, identity checks, and container checks between
@@ -413,6 +416,8 @@ section of the command line docs.
413416
``cache_dir`` (string, default ``.mypy_cache``)
414417
Specifies the location where mypy stores incremental cache info.
415418
User home directory and environment variables will be expanded.
419+
This setting will be overridden by the ``MYPY_CACHE_DIR`` environment
420+
variable.
416421

417422
Note that the cache is only read when incremental mode is enabled
418423
but is always written to, unless the value is set to ``/dev/nul``
@@ -436,6 +441,11 @@ section of the command line docs.
436441
``show_column_numbers`` (bool, default False)
437442
Shows column numbers in error messages.
438443

444+
``color_output`` (bool, default True)
445+
Shows error messages with color enabled.
446+
447+
``error_summary`` (bool, default True)
448+
Shows a short summary line after error messages.
439449

440450
Advanced options
441451
----------------

docs/source/final_attrs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Final names, methods and classes
55

66
This section introduces these related features:
77

8-
1. *Final names* are variables or attributes that should not reassigned after
8+
1. *Final names* are variables or attributes that should not be reassigned after
99
initialization. They are useful for declaring constants.
1010
2. *Final methods* should not be overridden in a subclass.
1111
3. *Final classes* should not be subclassed.

docs/source/protocols.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ be used in ``with`` and ``async with`` statements.
254254
Simple user-defined protocols
255255
*****************************
256256
257-
You can define your own protocol class by inheriting the special
258-
``typing_extensions.Protocol`` class:
257+
You can define your own protocol class by inheriting the special ``Protocol``
258+
class:
259259
260260
.. code-block:: python
261261
@@ -284,10 +284,9 @@ similarly compatible with the protocol, as they support ``close()``.
284284
285285
.. note::
286286
287-
The ``Protocol`` base class is currently provided in the ``typing_extensions``
288-
package. Once structural subtyping is mature and
289-
`PEP 544 <https://www.python.org/dev/peps/pep-0544/>`_ has been accepted,
290-
``Protocol`` will be included in the ``typing`` module.
287+
The ``Protocol`` base class is provided in the ``typing_extensions``
288+
package for Python 2.7 and 3.4-3.7. Starting with Python 3.8, ``Protocol``
289+
is included in the ``typing`` module.
291290
292291
Defining subprotocols and subclassing protocols
293292
***********************************************
@@ -319,8 +318,8 @@ and merged using multiple inheritance. Example:
319318
Note that inheriting from an existing protocol does not automatically
320319
turn the subclass into a protocol -- it just creates a regular
321320
(non-protocol) class or ABC that implements the given protocol (or
322-
protocols). The ``typing_extensions.Protocol`` base class must always
323-
be explicitly present if you are defining a protocol:
321+
protocols). The ``Protocol`` base class must always be explicitly
322+
present if you are defining a protocol:
324323
325324
.. code-block:: python
326325
@@ -383,14 +382,14 @@ Using ``isinstance()`` with protocols
383382
*************************************
384383
385384
You can use a protocol class with ``isinstance()`` if you decorate it
386-
with the ``typing_extensions.runtime`` class decorator. The decorator
387-
adds support for basic runtime structural checks:
385+
with the ``@runtime_checkable`` class decorator. The decorator adds
386+
support for basic runtime structural checks:
388387
389388
.. code-block:: python
390389
391-
from typing_extensions import Protocol, runtime
390+
from typing_extensions import Protocol, runtime_checkable
392391
393-
@runtime
392+
@runtime_checkable
394393
class Portable(Protocol):
395394
handles: int
396395

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy