Skip to content

Commit

Permalink
Merge branch 'main' into dict.get
Browse files Browse the repository at this point in the history
  • Loading branch information
tungol committed Dec 28, 2024
2 parents 7d13c25 + ff4237f commit e689fef
Show file tree
Hide file tree
Showing 355 changed files with 6,192 additions and 877 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,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 Down
35 changes: 26 additions & 9 deletions .github/workflows/mypy_primer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 3 additions & 6 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 Down Expand Up @@ -121,8 +120,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: 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 +181,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
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ select = [
"B", # flake8-bugbear
"FA", # flake8-future-annotations
"I", # isort
"PGH", # pygrep-hooks
"RUF", # Ruff-specific and unused-noqa
"UP", # pyupgrade
"YTT", # flake8-2020
# Flake8 base rules
"E", # pycodestyle Error
"F", # Pyflakes
Expand All @@ -56,16 +58,20 @@ select = [
"PYI014", # Only simple default values allowed for arguments
"PYI015", # Only simple default values allowed for assignments
"PYI016", # Duplicate union member `{}`
"PYI019", # Methods like `{method_name}` should return `Self` instead of a custom `TypeVar`
"PYI020", # Quoted annotations should not be included in stubs
"PYI025", # Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin
# "PYI026", Waiting for this mypy bug to be fixed: https://github.com/python/mypy/issues/16581
"PYI030", # Multiple literal members in a union. Use a single literal, e.g. `Literal[{}]`
"PYI032", # Prefer `object` to `Any` for the second parameter to `{method_name}`
"PYI034", # `__new__` methods usually return self at runtime
"PYI036", # Star-args in `{method_name}` should be annotated with `object`
"PYI044", # `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics
"PYI055", # Multiple `type[T]` usages in a union. Combine them into one, e.g., `type[{union_str}]`.
"PYI058", # Use `{return_type}` as the return value for simple `{method}` methods
# "PYI061", # TODO: Enable when out of preview
"PYI062", # Duplicate literal member `{}`
"PYI064", # `Final[Literal[{literal}]]` can be replaced with a bare Final
]
extend-safe-fixes = [
"UP036", # Remove unnecessary `sys.version_info` blocks
Expand Down
2 changes: 2 additions & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"stdlib/xml/sax",
"stubs/aiofiles/aiofiles/tempfile/temptypes.pyi",
"stubs/antlr4-python3-runtime",
"stubs/Authlib",
"stubs/aws-xray-sdk",
"stubs/beautifulsoup4",
"stubs/bleach/bleach/sanitizer.pyi",
Expand All @@ -38,6 +39,7 @@
"stubs/caldav",
"stubs/cffi",
"stubs/click-default-group",
"stubs/click-web",
"stubs/commonmark",
"stubs/corus",
"stubs/dateparser",
Expand Down
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Type checkers that we test our stubs against. These should always
# be pinned to a specific version to make failure reproducible.
mypy==1.13.0
mypy==1.14.0
pyright==1.1.389
# pytype can be installed on Windows, but requires building wheels, let's not do that on the CI
pytype==2024.10.11; platform_system != "Windows" and python_version >= "3.10" and python_version < "3.13"
Expand Down
Loading

0 comments on commit e689fef

Please sign in to comment.