Skip to content

Commit

Permalink
Merge branch 'main' into pathlib
Browse files Browse the repository at this point in the history
  • Loading branch information
tungol committed Jan 13, 2025
2 parents 0fb2a5d + 1017916 commit 16bff50
Show file tree
Hide file tree
Showing 829 changed files with 16,479 additions and 11,470 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
# As of 2024-10-18, ubuntu-latest can refer to different Ubuntu versions,
# which can can cause problems with os module constants.
os: ["ubuntu-24.04", "windows-latest", "macos-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false

steps:
Expand Down Expand Up @@ -119,8 +121,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: astral-sh/setup-uv@v5
- name: Run tests
run: |
cd stub_uploader
Expand All @@ -144,6 +145,6 @@ jobs:
owner: "python",
repo: "typeshed",
title: `Daily tests failed on ${new Date().toDateString()}`,
body: "Runs listed here: https://github.com/python/typeshed/actions/workflows/daily.yml",
body: "Run listed here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
labels: ["help wanted"],
})
1 change: 1 addition & 0 deletions .github/workflows/meta_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
paths:
- "scripts/**"
- "tests/**"
- "lib/**"
- ".github/workflows/meta_tests.yml"
- "requirements-tests.txt"
- "pyproject.toml"
Expand Down
37 changes: 27 additions & 10 deletions .github/workflows/mypy_primer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install dependencies
run: pip install git+https://github.com/hauntsaninja/mypy_primer.git
- name: Run mypy_primer
Expand All @@ -57,18 +57,35 @@ jobs:
--output concise \
| tee diff_${{ matrix.shard-index }}.txt
) || [ $? -eq 1 ]
- name: Upload mypy_primer diff
uses: actions/upload-artifact@v4
with:
name: mypy_primer_diff_${{ matrix.shard-index }}
path: diff_${{ matrix.shard-index }}.txt
- if: ${{ matrix.shard-index == 0 }}
name: Save PR number
run: |
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
- if: ${{ matrix.shard-index == 0 }}
name: Upload PR number
- name: Upload mypy_primer diff + PR number
uses: actions/upload-artifact@v4
if: ${{ matrix.shard-index == 0 }}
with:
name: mypy_primer_diffs-${{ matrix.shard-index }}
path: |
diff_${{ matrix.shard-index }}.txt
pr_number.txt
- name: Upload mypy_primer diff
uses: actions/upload-artifact@v4
if: ${{ matrix.shard-index != 0 }}
with:
name: mypy_primer_diffs-${{ matrix.shard-index }}
path: diff_${{ matrix.shard-index }}.txt

join_artifacts:
name: Join artifacts
runs-on: ubuntu-latest
needs: [mypy_primer]
permissions:
contents: read
steps:
- name: Merge artifacts
uses: actions/upload-artifact/merge@v4
with:
name: mypy_primer_diff_pr_number
path: pr_number.txt
name: mypy_primer_diffs
pattern: mypy_primer_diffs-*
delete-merged: true
31 changes: 16 additions & 15 deletions .github/workflows/mypy_primer_comment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Post mypy_primer comment
name: Comment with mypy_primer diff

on:
workflow_run:
Expand All @@ -14,8 +14,8 @@ permissions:
jobs:
comment:
name: Comment PR from mypy_primer
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download diffs
uses: actions/github-script@v7
Expand All @@ -27,28 +27,26 @@ jobs:
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const matchArtifacts = artifacts.data.artifacts.filter((artifact) =>
artifact.name.startsWith("mypy_primer_diff"));
const [matchArtifact] = artifacts.data.artifacts.filter((artifact) =>
artifact.name == "mypy_primer_diffs");
for (const matchArtifact of matchArtifacts) {
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: "zip",
});
fs.writeFileSync(`${matchArtifact.name}.zip`, Buffer.from(download.data));
}
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: "zip",
});
fs.writeFileSync("diff.zip", Buffer.from(download.data));
- run: for file in *.zip; do unzip $file; done
- run: unzip diff.zip
- run: |
cat diff_*.txt | tee fulldiff.txt
- name: Post comment
id: post-comment
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs')
let data = fs.readFileSync('fulldiff.txt', { encoding: 'utf8' })
Expand All @@ -61,6 +59,9 @@ jobs:
data = truncated_data + `\n\n... (truncated ${lines_truncated} lines) ...\n`
}
console.log("Diff from mypy_primer:")
console.log(data)
let body
if (data.trim()) {
body = 'Diff from [mypy_primer](https://github.com/hauntsaninja/mypy_primer), showing the effect of this PR on open source code:\n```diff\n' + data + '```'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stubsabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ jobs:
owner: "python",
repo: "typeshed",
title: `Stubsabot failed on ${new Date().toDateString()}`,
body: "Stubsabot runs are listed here: https://github.com/python/typeshed/actions/workflows/stubsabot.yml",
body: "Stubsabot run is listed here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
})
6 changes: 4 additions & 2 deletions .github/workflows/stubtest_stdlib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
# As of 2024-10-18, ubuntu-latest can refer to different Ubuntu versions,
# which can can cause problems with os module constants.
os: ["ubuntu-24.04", "windows-latest", "macos-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false

steps:
Expand Down
33 changes: 5 additions & 28 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
with:
# Max supported Python version as of pytype 2024.9.13
python-version: "3.12"
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: astral-sh/setup-uv@v5
- run: uv pip install -r requirements-tests.txt --system
- name: Install external dependencies for 3rd-party stubs
run: |
Expand All @@ -63,7 +62,7 @@ jobs:
strategy:
matrix:
platform: ["linux", "win32", "darwin"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand All @@ -74,26 +73,6 @@ jobs:
- run: uv pip install -r requirements-tests.txt --system
- run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }}

# Run this as a separate job, as the other versions in the matrix are
# (and should be) run *using* the Python version we're testing the stubs for,
# but we can't install all our non-types dependencies on py313 yet
mypy-313:
name: Run mypy against the 3.13 stubs
runs-on: ubuntu-latest
strategy:
matrix:
platform: ["linux", "win32", "darwin"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
allow-prereleases: true
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
- run: uv pip install -r requirements-tests.txt --system
- run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=3.13

regression-tests:
name: Run mypy on the test cases
runs-on: ubuntu-latest
Expand All @@ -114,15 +93,14 @@ jobs:
strategy:
matrix:
python-platform: ["Linux", "Windows", "Darwin"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: astral-sh/setup-uv@v5
- name: Install typeshed test-suite requirements
# Install these so we can run `get_external_stub_requirements.py`
run: uv pip install -r requirements-tests.txt --system
Expand Down Expand Up @@ -183,8 +161,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: astral-sh/setup-uv@v5
- name: Run tests
run: |
cd stub_uploader
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
args: [--fix=lf]
- id: check-case-conflict
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1 # must match requirements-tests.txt
rev: v0.8.6 # must match requirements-tests.txt
hooks:
- id: ruff
name: Run ruff on stubs, tests and scripts
Expand All @@ -34,6 +34,7 @@ repos:
rev: 7.1.1
hooks:
- id: flake8
language: python
additional_dependencies:
- "flake8-noqa==1.4.0"
- "flake8-pyi==24.9.0"
Expand Down
5 changes: 3 additions & 2 deletions .vscode/settings.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeActionsOnSave": {
// Let Ruff lint fixes handle imports
"source.organizeImports": "never"
"source.organizeImports": "never",
"source.unusedImports": "never"
}
},
// python.analysis is Pylance (pyright) configurations
"python.analysis.fixAll": [
"source.unusedImports"
// Explicitly omiting "source.convertImportFormat", some stubs use relative imports
// Explicitly omiting "source.unusedImports", Let Ruff lint fixes handle imports
],
"python.analysis.typeshedPaths": [
"${workspaceFolder}"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ the project the stubs are for, but instead report them here to typeshed.**
Further documentation on stub files, typeshed, and Python's typing system in
general, can also be found at https://typing.readthedocs.io/en/latest/.

Typeshed supports Python versions 3.8 to 3.13.
Typeshed supports Python versions 3.9 to 3.13.

## Using

Expand Down
9 changes: 5 additions & 4 deletions lib/ts_utils/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

__all__ = [
"NoSuchStubError",
"StubMetadata",
"PackageDependencies",
"StubMetadata",
"StubtestSettings",
"get_recursive_requirements",
"read_dependencies",
Expand Down Expand Up @@ -184,7 +184,7 @@ def is_obsolete(self) -> bool:


class NoSuchStubError(ValueError):
"""Raise NoSuchStubError to indicate that a stubs/{distribution} directory doesn't exist"""
"""Raise NoSuchStubError to indicate that a stubs/{distribution} directory doesn't exist."""


@cache
Expand Down Expand Up @@ -302,9 +302,10 @@ def read_metadata(distribution: str) -> StubMetadata:


def update_metadata(distribution: str, **new_values: object) -> tomlkit.TOMLDocument:
"""Updates a distribution's METADATA.toml.
"""Update a distribution's METADATA.toml.
Return the updated TOML dictionary for use without having to open the file separately."""
Return the updated TOML dictionary for use without having to open the file separately.
"""
path = metadata_path(distribution)
try:
with path.open("rb") as file:
Expand Down
3 changes: 1 addition & 2 deletions lib/ts_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from termcolor import colored as colored # pyright: ignore[reportAssignmentType]
except ImportError:

def colored(text: str, color: str | None = None, **kwargs: Any) -> str: # type: ignore[misc]
def colored(text: str, color: str | None = None, **kwargs: Any) -> str: # type: ignore[misc] # noqa: ARG001
return text


Expand Down Expand Up @@ -92,7 +92,6 @@ def venv_python(venv_dir: Path) -> Path:
@cache
def parse_requirements() -> Mapping[str, Requirement]:
"""Return a dictionary of requirements from the requirements file."""

with REQUIREMENTS_PATH.open(encoding="UTF-8") as requirements_file:
stripped_lines = map(strip_comments, requirements_file)
stripped_more = [li for li in stripped_lines if not li.startswith("-")]
Expand Down
Loading

0 comments on commit 16bff50

Please sign in to comment.