Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into add-main-2
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Jul 8, 2023
2 parents 142813d + 6cd8c00 commit 3280eec
Show file tree
Hide file tree
Showing 364 changed files with 11,489 additions and 3,854 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
97c5ee99bc98dc475512e549b252b23a6e7e0997
# Use builtin generics and PEP 604 for type annotations wherever possible (#13427)
23ee1e7aff357e656e3102435ad0fe3b5074571e
# Use variable annotations (#10723)
f98f78216ba9d6ab68c8e69c19e9f3c7926c5efe
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ contact_links:
- about: "Please check the linked documentation page before filing new issues."
name: "Common issues and solutions"
url: "https://mypy.readthedocs.io/en/stable/common_issues.html"
- about: "Please ask and answer any questions on the mypy Gitter."
- about: "Please ask and answer any questions on the python/typing Gitter."
name: "Questions or Chat"
url: "https://gitter.im/python/typing"
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
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ jobs:
env:
TOXENV: docs
TOX_SKIP_MISSING_INTERPRETERS: False
VERIFY_MYPY_ERROR_CODES: 1
steps:
- 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
51 changes: 22 additions & 29 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,33 +60,36 @@ 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
- name: Formatting with Black + isort and code style with flake8
- name: Formatting and code style with Black + ruff
python: '3.10'
arch: x64
os: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@ test_capi
*.o
*.a
test_capi
/.mypyc-flake8-cache.json
/mypyc/lib-rt/build/
/mypyc/lib-rt/*.so
20 changes: 5 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,12 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
- repo: https://github.com/hauntsaninja/black-pre-commit-mirror
rev: 23.3.0 # must match test-requirements.txt
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0 # must match test-requirements.txt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.272 # must match test-requirements.txt
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.0.0 # must match test-requirements.txt
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.3.23 # must match test-requirements.txt
- flake8-noqa==1.3.1 # must match test-requirements.txt

ci:
# We run flake8 as part of our GitHub Actions suite in CI
skip: [flake8]
- id: ruff
args: [--exit-non-zero-on-fix]
18 changes: 18 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

sphinx:
configuration: docs/source/conf.py

formats: [pdf, htmlzip, epub]

python:
install:
- requirements: docs/requirements-docs.txt
11 changes: 2 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ pytest -n0 -k 'test_name'
# Run all test cases in the "test-data/unit/check-dataclasses.test" file
pytest mypy/test/testcheck.py::TypeCheckSuite::check-dataclasses.test

# Run the linter
flake8

# Run formatters
black . && isort .
# Run the formatters and linters
python runtests.py lint
```

For an in-depth guide on running and writing tests,
Expand Down Expand Up @@ -154,10 +151,6 @@ advice about good pull requests for open-source projects applies; we
have [our own writeup](https://github.com/python/mypy/wiki/Good-Pull-Request)
of this advice.

We are using `black` and `isort` to enforce a consistent coding style.
Run `black . && isort .` before your commits, otherwise you would receive
a CI failure.

Also, do not squash your commits after you have submitted a pull request, as this
erases context during review. We will squash commits when the pull request is merged.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Mypy: Static Typing for Python
[![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)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Linting: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

Got a question?
---------------
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
2 changes: 0 additions & 2 deletions docs/source/cheat_sheet_py3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ Classes
class AuditedBankAccount(BankAccount):
# You can optionally declare instance variables in the class body
audit_log: list[str]
# This is an instance variable with a default value
auditor_name: str = "The Spanish Inquisition"
def __init__(self, account_name: str, initial_balance: int = 0) -> None:
super().__init__(account_name, initial_balance)
Expand Down
28 changes: 28 additions & 0 deletions docs/source/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,34 @@ of the above sections.
assert text is not None # OK, check against None is allowed as a special case.
.. option:: --extra-checks

This flag enables additional checks that are technically correct but may be
impractical in real code. In particular, it prohibits partial overlap in
``TypedDict`` updates, and makes arguments prepended via ``Concatenate``
positional-only. For example:

.. code-block:: python
from typing import TypedDict
class Foo(TypedDict):
a: int
class Bar(TypedDict):
a: int
b: int
def test(foo: Foo, bar: Bar) -> None:
# This is technically unsafe since foo can have a subtype of Foo at
# runtime, where type of key "b" is incompatible with int, see below
bar.update(foo)
class Bad(Foo):
b: str
bad: Bad = {"a": 0, "b": "no"}
test(bad, bar)
.. option:: --strict

This flag mode enables all optional error checking flags. You can see the
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.intersphinx"]
extensions = ["sphinx.ext.intersphinx", "docs.source.html_builder"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
2 changes: 1 addition & 1 deletion docs/source/config_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ section of the command line docs.

.. confval:: no_site_packages

:type: bool
:type: boolean
:default: False

Disables using type information in installed packages (see :pep:`561`).
Expand Down
Loading

0 comments on commit 3280eec

Please sign in to comment.