Skip to content

Commit

Permalink
Merge branch 'python:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Jun 14, 2023
2 parents 9cffc46 + c38fc45 commit d63a826
Show file tree
Hide file tree
Showing 3,065 changed files with 102,340 additions and 38,406 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
35 changes: 19 additions & 16 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# The following rules come from plugins that are not used by typeshed.
# Since typeshed stubs them, they can still be expected to be found in a
# developer's venv for intellisense and reference reasons
# A flake8-builtins
# D flake8-docstrings
# N8 pep8-naming
# SIM flake8-simplify
# RST flake8-rst-docstrings
# TYP flake8-typing-imports

# The following rules are incompatible with or enforced by black:
# E203 whitespace before ':' -- scripts only
# E301 expected 1 blank line
Expand All @@ -6,37 +16,30 @@
# E501 line too long

# Some rules are considered irrelevant to stub files:
# B All flake8-bugbear rules are .py-specific
# E701 multiple statements on one line (colon) -- disallows "..." on the same line
# F401 imported but unused -- does not recognize re-exports
# https://github.com/PyCQA/pyflakes/issues/474
# F822 undefined name in __all__ -- flake8 does not recognize 'foo: Any'
# https://github.com/PyCQA/pyflakes/issues/533

# Rules that are out of the control of stub authors:
# E741 ambiguous variable name
# F403 import *' used; unable to detect undefined names
# F405 defined from star imports

# Rules that we'd like to enable in the future:
# Y037 Use PEP 604 syntax instead of `typing.Union` and `typing.Optional`.
# Currently can't be enabled due to a few lingering bugs in mypy regarding
# PEP 604 type aliases (see #4819).
# NQA102 "noqa" code has no matching violations. We often introduce "noqa" comments
# into the typeshed codebase to unblock flake8-pyi PRs, meaning these comments
# have "no matching violations" since the relevant flake8-pyi checks haven't
# yet been released.

[flake8]
extend-ignore = A, D, N8, SIM, RST, TYP, E301, E302, E305, E501
per-file-ignores =
*.py: E203, E301, E302, E305, E501
*.pyi: E301, E302, E305, E501, E701, E741, NQA102, F401, F403, F405, F822, Y037
*.py: E203
*.pyi: B, E701, E741, F401, F403, F405
# Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload.
# Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself.
# https://github.com/PyCQA/flake8/issues/1079
# F811 redefinition of unused '...'
stdlib/typing.pyi: E301, E302, E305, E501, E701, E741, NQA102, F401, F403, F405, F811, F822, Y037
stdlib/typing.pyi: B, E701, E741, F401, F403, F405, F811
# Generated protobuf files include docstrings
*_pb2.pyi: E301, E302, E305, E501, E701, NQA102, Y021, Y026
# *_pb2.pyi: B, E701, E741, F401, F403, F405, Y021, Y026, Y053, Y054

exclude = .venv*,.git
# TODO: Re-enable flake8 on generated protobuf files
# after https://github.com/nipunn1313/mypy-protobuf/issues/523 is resolved
exclude = .venv*,.git,*_pb2.pyi
noqa_require_code = true
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Set linguist-language to support comments syntax highlight
**/stubtest_allowlist*.txt linguist-language=ini
tests/stubtest_allowlists/*.txt linguist-language=ini
tests/pytype_exclude_list.txt linguist-language=ini
pyrightconfig*.json linguist-language=jsonc
.vscode/*.json linguist-language=jsonc
66 changes: 53 additions & 13 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@ on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
pull_request:
paths:
- "requirements-tests.txt"
- ".github/workflows/daily.yml"

# Please keep the permissions minimal, as stubtest runs arbitrary code from pypi.
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
# A few env vars to speedup brew install
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTOUPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1 # Environments are isolated, no need to cleanup old versions
NONINTERACTIVE: 1 # Required for brew install on CI
PIP_DISABLE_PIP_VERSION_CHECK: 1
FORCE_COLOR: 1
TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817

jobs:
stubtest-stdlib:
Expand All @@ -19,8 +34,9 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
# tkinter doesn't import on macOS-12
os: ["ubuntu-latest", "windows-latest", "macos-11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
fail-fast: false

steps:
Expand All @@ -29,35 +45,57 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install -U pip
cache: pip
cache-dependency-path: requirements-tests.txt
- name: Install dependencies
run: pip install $(grep tomli== requirements-tests.txt) $(grep mypy== requirements-tests.txt)
run: pip install -r requirements-tests.txt
- name: Run stubtest
run: python tests/stubtest_stdlib.py

stubtest-third-party:
name: Check third party stubs with stubtest
if: ${{ github.repository == 'python/typeshed' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-20.04
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
shard-index: [0, 1, 2, 3]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.10"
cache: pip
cache-dependency-path: |
requirements-tests.txt
stubs/**/METADATA.toml
- name: Install dependencies
run: pip install -r requirements-tests.txt
- name: Install apt packages
run: |
sudo apt update
sudo apt install -y $(python tests/get_apt_packages.py)
- name: Run stubtest
run: xvfb-run python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }}
shell: bash
run: |
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
if [ "${{ runner.os }}" = "Linux" ]; then
if [ -n "$PACKAGES" ]; then
sudo apt update && sudo apt install -y $PACKAGES
fi
PYTHON_EXECUTABLE="xvfb-run python"
else
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
brew install $PACKAGES
fi
if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
choco install -y $PACKAGES
fi
PYTHON_EXECUTABLE="python"
fi
$PYTHON_EXECUTABLE tests/stubtest_third_party.py --specified-platforms-only --num-shards 4 --shard-index ${{ matrix.shard-index }}
stub-uploader:
name: Run the stub_uploader tests
runs-on: ubuntu-latest
Expand All @@ -75,6 +113,8 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
cache-dependency-path: stub_uploader/requirements.txt
- name: Run tests
run: |
cd stub_uploader
Expand All @@ -86,7 +126,7 @@ jobs:
name: Create an issue if daily tests failed
runs-on: ubuntu-latest
needs: [stubtest-stdlib, stubtest-third-party, stub-uploader]
if: ${{ github.repository == 'python/typeshed' && always() && (needs.stubtest-stdlib.result == 'failure' || needs.stubtest-third-party.result == 'failure' || needs.stub-uploader.result == 'failure') }}
if: ${{ github.repository == 'python/typeshed' && always() && github.event_name != 'pull_request' && (needs.stubtest-stdlib.result == 'failure' || needs.stubtest-third-party.result == 'failure' || needs.stub-uploader.result == 'failure') }}
permissions:
issues: write
steps:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/mypy_primer.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Run mypy_primer

on:
# Only run on PR, since we diff against master
# Only run on PR, since we diff against main
pull_request:
paths:
- 'stdlib/**'
- 'stubs/**'
- '.github/workflows/mypy_primer.yml'
- '.github/workflows/mypy_primer_comment.yml'
- "stdlib/**"
- "stubs/**/*.pyi"
- ".github/workflows/mypy_primer.yml"
- ".github/workflows/mypy_primer_comment.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -31,7 +31,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- name: Install dependencies
run: pip install git+https://github.com/hauntsaninja/mypy_primer.git
- name: Run mypy_primer
Expand All @@ -41,17 +41,17 @@ jobs:
MYPY_VERSION=$(grep mypy== requirements-tests.txt | cut -d = -f 3)
echo "new commit"
git rev-list --format=%s --max-count=1 $GITHUB_SHA
git checkout -b upstream_master origin/master
git checkout -b upstream_main origin/main
echo "base commit"
git rev-list --format=%s --max-count=1 upstream_master
git rev-list --format=%s --max-count=1 upstream_main
echo ''
cd ..
# fail action if exit code isn't zero or one
(
mypy_primer \
--new v${MYPY_VERSION} --old v${MYPY_VERSION} \
--custom-typeshed-repo typeshed_to_test \
--new-typeshed $GITHUB_SHA --old-typeshed upstream_master \
--new-typeshed $GITHUB_SHA --old-typeshed upstream_main \
--num-shards 4 --shard-index ${{ matrix.shard-index }} \
--debug \
--output concise \
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/mypy_primer_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ jobs:
script: |
const fs = require('fs')
let data = fs.readFileSync('fulldiff.txt', { encoding: 'utf8' })
// posting comment fails if too long, so truncate
if (data.length > 30000) {
let truncated_data = data.substring(0, 30000)
// Maximum comment length is 65536 characters. We need much less than 236 for extra text.
const MAX_LENGTH = 65300
if (data.length > MAX_LENGTH) {
let truncated_data = data.substring(0, MAX_LENGTH)
let lines_truncated = data.split('\n').length - truncated_data.split('\n').length
data = truncated_data + `\n\n... (truncated ${lines_truncated} lines) ...\n`
}
Expand All @@ -74,8 +76,8 @@ jobs:
return prNumber
- name: Hide old comments
# v0.3.0
uses: kanga333/comment-hider@bbdf5b562fbec24e6f60572d8f712017428b92e0
# v0.4.0
uses: kanga333/comment-hider@c12bb20b48aeb8fc098e35967de8d4f8018fffdf
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
leave_visible: 1
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/stubsabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ permissions:
issues: write
pull-requests: write

env:
FORCE_COLOR: 1

jobs:
stubsabot:
name: Upgrade stubs with stubsabot
Expand All @@ -24,6 +27,8 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
cache-dependency-path: requirements-tests.txt
- name: git config
run: |
git config --global user.name stubsabot
Expand Down
24 changes: 13 additions & 11 deletions .github/workflows/stubtest_stdlib.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
name: Run stubtest
name: Stdlib stubtest

on:
workflow_dispatch:
push:
branches:
- main
- master
pull_request:
paths:
- 'stdlib/**'
- '.github/workflows/stubtest_stdlib.yml'
- 'tests/**'
- 'requirements-tests.txt'
- "stdlib/**"
- ".github/workflows/stubtest_stdlib.yml"
- "tests/**"
# When requirements.txt changes, we run `daily.yml`, which includes stdlib stubtest

permissions:
contents: read

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
FORCE_COLOR: 1
TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -29,8 +30,9 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
# tkinter doesn't import on macOS 12
os: ["ubuntu-latest", "windows-latest", "macos-11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
fail-fast: false

steps:
Expand All @@ -39,9 +41,9 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install -U pip
cache: pip
cache-dependency-path: requirements-tests.txt
- name: Install dependencies
run: pip install $(grep mypy== requirements-tests.txt)
run: pip install -r requirements-tests.txt
- name: Run stubtest
run: python tests/stubtest_stdlib.py
Loading

0 comments on commit d63a826

Please sign in to comment.