Skip to content

Commit

Permalink
Merge branch 'master' into mypyc-u8
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja authored Jul 4, 2023
2 parents 794b0b9 + 1e14d13 commit 82a0527
Show file tree
Hide file tree
Showing 137 changed files with 611 additions and 769 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.11'
- name: Trigger script
env:
WHEELS_PUSH_TOKEN: ${{ secrets.WHEELS_PUSH_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'
- name: Install tox
run: pip install --upgrade 'setuptools!=50' tox==4.4.4
- name: Setup tox environment
Expand Down
49 changes: 21 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,27 @@ jobs:
fail-fast: false
matrix:
include:
- name: Test suite with py37-windows-64
python: '3.7'
arch: x64
os: windows-latest
toxenv: py37
- name: Test suite with py38-ubuntu
# Make sure to run mypyc compiled unit tests for both
# the oldest and newest supported Python versions
- name: Test suite with py38-ubuntu, mypyc-compiled
python: '3.8'
arch: x64
os: ubuntu-latest
toxenv: py
tox_extra_args: "-n 2"
- name: Test suite with py39-ubuntu
python: '3.9'
arch: x64
os: ubuntu-latest
toxenv: py
tox_extra_args: "-n 2"
- name: Test suite with py37-ubuntu, mypyc-compiled
python: '3.7'
test_mypyc: true
- name: Test suite with py38-windows-64
python: '3.8'
arch: x64
os: ubuntu-latest
toxenv: py
os: windows-latest
toxenv: py38
tox_extra_args: "-n 2"
test_mypyc: true
- name: Test suite with py310-ubuntu, mypyc-compiled
python: '3.10'
- name: Test suite with py39-ubuntu
python: '3.9'
arch: x64
os: ubuntu-latest
toxenv: py
tox_extra_args: "-n 2"
test_mypyc: true
- name: Test suite with py310-ubuntu
python: '3.10'
arch: x64
Expand All @@ -70,29 +60,32 @@ jobs:
toxenv: py
tox_extra_args: "-n 2"
test_mypyc: true
- name: mypyc runtime tests with py37-macos
python: '3.7'

- name: mypyc runtime tests with py38-macos
python: '3.8.17'
arch: x64
os: macos-latest
toxenv: py
tox_extra_args: "-n 2 mypyc/test/test_run.py mypyc/test/test_external.py"
- name: mypyc runtime tests with py37-debug-build-ubuntu
python: '3.7.13'
- name: mypyc runtime tests with py38-debug-build-ubuntu
python: '3.8.17'
arch: x64
os: ubuntu-latest
toxenv: py
tox_extra_args: "-n 2 mypyc/test/test_run.py mypyc/test/test_external.py"
debug_build: true
- name: Type check our own code (py37-ubuntu)
python: '3.7'

- name: Type check our own code (py38-ubuntu)
python: '3.8'
arch: x64
os: ubuntu-latest
toxenv: type
- name: Type check our own code (py37-windows-64)
python: '3.7'
- name: Type check our own code (py38-windows-64)
python: '3.8'
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
Expand Down
1 change: 0 additions & 1 deletion build-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
-r mypy-requirements.txt
types-psutil
types-setuptools
types-typed-ast>=1.5.8.5,<1.6.0
7 changes: 3 additions & 4 deletions docs/source/additional_features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ of the previous sections.
Dataclasses
***********

In Python 3.7, a new :py:mod:`dataclasses` module has been added to the standard library.
This module allows defining and customizing simple boilerplate-free classes.
They can be defined using the :py:func:`@dataclasses.dataclass
<python:dataclasses.dataclass>` decorator:
The :py:mod:`dataclasses` module allows defining and customizing simple
boilerplate-free classes. They can be defined using the
:py:func:`@dataclasses.dataclass <python:dataclasses.dataclass>` decorator:

.. code-block:: python
Expand Down
4 changes: 2 additions & 2 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ may not make much sense otherwise.
Installing and running mypy
***************************

Mypy requires Python 3.7 or later to run. You can install mypy using pip:
Mypy requires Python 3.8 or later to run. You can install mypy using pip:

.. code-block:: shell
Expand Down Expand Up @@ -264,7 +264,7 @@ Python standard library. For example, here is a function which uses the
from pathlib import Path
def load_template(template_path: Path, name: str) -> str:
# Mypy knows that `file_path` has a `read_text` method that returns a str
# Mypy knows that `template_path` has a `read_text` method that returns a str
template = template_path.read_text()
# ...so it understands this line type checks
return template.replace('USERNAME', name)
Expand Down
4 changes: 2 additions & 2 deletions misc/analyze_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import os
import os.path
from collections import Counter
from typing import Any, Dict, Iterable
from typing_extensions import Final, TypeAlias as _TypeAlias
from typing import Any, Dict, Final, Iterable
from typing_extensions import TypeAlias as _TypeAlias

ROOT: Final = ".mypy_cache/3.5"

Expand Down
2 changes: 1 addition & 1 deletion misc/build-debug-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi
curl -O https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz
tar zxf Python-$VERSION.tgz
cd Python-$VERSION
CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" ./configure CFLAGS="-DPy_DEBUG -DPy_TRACE_REFS -DPYMALLOC_DEBUG" --with-pydebug --prefix=$PREFIX
CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" ./configure CFLAGS="-DPy_DEBUG -DPy_TRACE_REFS -DPYMALLOC_DEBUG" --with-pydebug --prefix=$PREFIX --with-trace-refs
make -j4
make install
$PREFIX/bin/python3 -m pip install virtualenv
Expand Down
4 changes: 2 additions & 2 deletions misc/incremental_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import textwrap
import time
from argparse import ArgumentParser, Namespace, RawDescriptionHelpFormatter
from typing import Any, Dict
from typing_extensions import Final, TypeAlias as _TypeAlias
from typing import Any, Dict, Final
from typing_extensions import TypeAlias as _TypeAlias

CACHE_PATH: Final = ".incremental_checker_cache.json"
MYPY_REPO_URL: Final = "https://github.com/python/mypy.git"
Expand Down
24 changes: 19 additions & 5 deletions misc/sync-typeshed.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,27 @@ def main() -> None:
print("Created typeshed sync commit.")

commits_to_cherry_pick = [
"6f913a148", # LiteralString reverts
"475a46a78", # sum reverts
"f5e5c117d", # ctypes reverts
"9f3bbbeb1", # ParamSpec for functools.wraps
"9f4c0d8af", # LiteralString reverts
"56f434336", # sum reverts
"71c4269df", # ctypes reverts
"186fbb18e", # ParamSpec for functools.wraps
]
for commit in commits_to_cherry_pick:
subprocess.run(["git", "cherry-pick", commit], check=True)
try:
subprocess.run(["git", "cherry-pick", commit], check=True)
except subprocess.CalledProcessError:
if not sys.__stdin__.isatty():
# We're in an automated context
raise

# Allow the option to merge manually
print(
f"Commit {commit} failed to cherry pick."
" In a separate shell, please manually merge and continue cherry pick."
)
rsp = input("Did you finish the cherry pick? [y/N]: ")
if rsp.lower() not in {"y", "yes"}:
raise
print(f"Cherry-picked {commit}.")

if args.make_pr:
Expand Down
4 changes: 1 addition & 3 deletions mypy-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml
typing_extensions>=4.1.0; python_version >= '3.8'
typing_extensions>=4.7.0; python_version < '3.8'
typing_extensions>=4.1.0
mypy_extensions>=1.0.0
typed_ast>=1.4.0,<2; python_version<'3.8'
tomli>=1.1.0; python_version<'3.11'
3 changes: 2 additions & 1 deletion mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
Callable,
ClassVar,
Dict,
Final,
Iterator,
Mapping,
NamedTuple,
NoReturn,
Sequence,
TextIO,
)
from typing_extensions import Final, TypeAlias as _TypeAlias, TypedDict
from typing_extensions import TypeAlias as _TypeAlias, TypedDict

import mypy.semanal_main
from mypy.checker import TypeChecker
Expand Down
5 changes: 3 additions & 2 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
AbstractSet,
Callable,
Dict,
Final,
Generic,
Iterable,
Iterator,
Expand All @@ -22,7 +23,7 @@
cast,
overload,
)
from typing_extensions import Final, TypeAlias as _TypeAlias
from typing_extensions import TypeAlias as _TypeAlias

import mypy.checkexpr
from mypy import errorcodes as codes, message_registry, nodes, operators
Expand Down Expand Up @@ -1546,7 +1547,7 @@ def check_reverse_op_method(
if opt_meta is not None:
forward_inst = opt_meta

def has_readable_member(typ: Union[UnionType, Instance], name: str) -> bool:
def has_readable_member(typ: UnionType | Instance, name: str) -> bool:
# TODO: Deal with attributes of TupleType etc.
if isinstance(typ, Instance):
return typ.type.has_readable_member(name)
Expand Down
6 changes: 3 additions & 3 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import time
from collections import defaultdict
from contextlib import contextmanager
from typing import Callable, ClassVar, Iterable, Iterator, List, Optional, Sequence, cast
from typing_extensions import Final, TypeAlias as _TypeAlias, overload
from typing import Callable, ClassVar, Final, Iterable, Iterator, List, Optional, Sequence, cast
from typing_extensions import TypeAlias as _TypeAlias, overload

import mypy.checker
import mypy.errorcodes as codes
Expand Down Expand Up @@ -5581,7 +5581,7 @@ def replace_callable_return_type(c: CallableType, new_ret_type: Type) -> Callabl
return c.copy_modified(ret_type=new_ret_type)


def apply_poly(tp: CallableType, poly_tvars: Sequence[TypeVarLikeType]) -> Optional[CallableType]:
def apply_poly(tp: CallableType, poly_tvars: Sequence[TypeVarLikeType]) -> CallableType | None:
"""Make free type variables generic in the type if possible.
This will translate the type `tp` while trying to create valid bindings for
Expand Down
3 changes: 1 addition & 2 deletions mypy/checkpattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from __future__ import annotations

from collections import defaultdict
from typing import NamedTuple
from typing_extensions import Final
from typing import Final, NamedTuple

import mypy.checker
from mypy import message_registry
Expand Down
4 changes: 2 additions & 2 deletions mypy/checkstrformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from __future__ import annotations

import re
from typing import TYPE_CHECKING, Callable, Dict, Match, Pattern, Tuple, Union, cast
from typing_extensions import Final, TypeAlias as _TypeAlias
from typing import TYPE_CHECKING, Callable, Dict, Final, Match, Pattern, Tuple, Union, cast
from typing_extensions import TypeAlias as _TypeAlias

import mypy.errorcodes as codes
from mypy.errors import Errors
Expand Down
3 changes: 2 additions & 1 deletion mypy/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Any,
Callable,
Dict,
Final,
Iterable,
List,
Mapping,
Expand All @@ -28,7 +29,7 @@
Tuple,
Union,
)
from typing_extensions import Final, TypeAlias as _TypeAlias
from typing_extensions import TypeAlias as _TypeAlias

from mypy import defaults
from mypy.options import PER_MODULE_OPTIONS, Options
Expand Down
3 changes: 1 addition & 2 deletions mypy/constant_fold.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

from __future__ import annotations

from typing import Union
from typing_extensions import Final
from typing import Final, Union

from mypy.nodes import (
ComplexExpr,
Expand Down
3 changes: 1 addition & 2 deletions mypy/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Iterable, List, Sequence, cast
from typing_extensions import Final
from typing import TYPE_CHECKING, Final, Iterable, List, Sequence, cast

import mypy.subtypes
import mypy.typeops
Expand Down
4 changes: 2 additions & 2 deletions mypy/defaults.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import annotations

import os
from typing_extensions import Final
from typing import Final

PYTHON2_VERSION: Final = (2, 7)

# Earliest fully supported Python 3.x version. Used as the default Python
# version in tests. Mypy wheels should be built starting with this version,
# and CI tests should be run on this version (and later versions).
PYTHON3_VERSION: Final = (3, 7)
PYTHON3_VERSION: Final = (3, 8)

# Earliest Python 3.x version supported via --python-version 3.x. To run
# mypy, at least version PYTHON3_VERSION is needed.
Expand Down
6 changes: 2 additions & 4 deletions mypy/dmypy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import time
import traceback
from contextlib import redirect_stderr, redirect_stdout
from typing import AbstractSet, Any, Callable, List, Sequence, Tuple
from typing_extensions import Final, TypeAlias as _TypeAlias
from typing import AbstractSet, Any, Callable, Final, List, Sequence, Tuple
from typing_extensions import TypeAlias as _TypeAlias

import mypy.build
import mypy.errors
Expand Down Expand Up @@ -896,8 +896,6 @@ def cmd_inspect(
force_reload: bool = False,
) -> dict[str, object]:
"""Locate and inspect expression(s)."""
if sys.version_info < (3, 8):
return {"error": 'Python 3.8 required for "inspect" command'}
if not self.fine_grained_manager:
return {
"error": 'Command "inspect" is only valid after a "check" command'
Expand Down
3 changes: 1 addition & 2 deletions mypy/dmypy_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from __future__ import annotations

import json
from typing import Any
from typing_extensions import Final
from typing import Any, Final

from mypy.ipc import IPCBase

Expand Down
2 changes: 1 addition & 1 deletion mypy/errorcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from __future__ import annotations

from collections import defaultdict
from typing_extensions import Final
from typing import Final

from mypy_extensions import mypyc_attr

Expand Down
Loading

0 comments on commit 82a0527

Please sign in to comment.