Skip to content

Commit b43e975

Browse files
committed
Merge branch 'main' of https://github.com/PyCQA/pylint into del-iterating
2 parents e66d0b6 + fadf6ea commit b43e975

File tree

847 files changed

+17693
-9973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

847 files changed

+17693
-9973
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ Thank you for submitting a PR to pylint!
33
44
To ease the process of reviewing your PR, do make sure to complete the following boxes.
55
6-
- [ ] Add a ChangeLog entry describing what your PR does.
7-
- [ ] If it's a new feature, or an important bug fix, add a What's New entry in
8-
`doc/whatsnew/<current release.rst>`.
96
- [ ] Write a good description on what the PR does.
7+
- [ ] If it's a new feature, or an important bug fix, add a What's New entry in
8+
``doc/whatsnew/2/2.14/summary.rst`` otherwise in ``doc/whatsnew/2/2.14/full.rst``.
109
- [ ] If you used multiple emails or multiple names when contributing, add your mails
11-
and preferred name in ``script/.contributors_aliases.json``
10+
and preferred name in ``script/.contributors_aliases.json``
1211
-->
1312

1413
## Type of Changes
@@ -24,9 +23,10 @@ To ease the process of reviewing your PR, do make sure to complete the following
2423

2524
## Description
2625

27-
<!--
28-
If this PR fixes a particular issue, use the following to automatically close that issue
29-
once this PR gets merged:
30-
-->
26+
<!-- If this PR references an issue without fixing it: -->
27+
28+
Refs #XXXX
29+
30+
<!-- If this PR fixes an issue, use the following to automatically close when we merge: -->
3131

32-
Closes #XXX
32+
Closes #XXXX

.github/workflows/checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
env:
1111
# Also change CACHE_VERSION in the other workflows
12-
CACHE_VERSION: 6
12+
CACHE_VERSION: 7
1313
DEFAULT_PYTHON: 3.8
1414
PRE_COMMIT_CACHE: ~/.cache/pre-commit
1515

.github/workflows/primer_comment.yaml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Most of this is inspired by the mypy primer
2+
# See: https://github.com/hauntsaninja/mypy_primer
3+
# This is the primer job that creates the comment on the PR
4+
# It needs to trigger on workflow_run instead of pull_request
5+
# as we need repository wide access to create a comment
6+
7+
name: Primer / Comment
8+
9+
on:
10+
workflow_run:
11+
workflows: [Primer / Run]
12+
types:
13+
- completed
14+
15+
env:
16+
CACHE_VERSION: 1
17+
18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
22+
jobs:
23+
primer-comment:
24+
name: Run
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/setup-node@v1
28+
with:
29+
version: 12
30+
- run: npm install @octokit/rest
31+
- name: Check out code from GitHub
32+
uses: actions/[email protected]
33+
- name: Set up Python 3.8
34+
id: python
35+
uses: actions/[email protected]
36+
with:
37+
python-version: 3.8
38+
39+
# Restore cached Python environment
40+
- name: Generate partial Python venv restore key
41+
id: generate-python-key
42+
run: >-
43+
echo "::set-output name=key::venv-${{ env.CACHE_VERSION }}-${{
44+
hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt')
45+
}}"
46+
- name: Restore Python virtual environment
47+
id: cache-venv
48+
uses: actions/[email protected]
49+
with:
50+
path: venv
51+
key: >-
52+
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
53+
steps.generate-python-key.outputs.key }}
54+
restore-keys: |
55+
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ env.CACHE_VERSION }}-
56+
- name: Create Python virtual environment
57+
if: steps.cache-venv.outputs.cache-hit != 'true'
58+
run: |
59+
python -m venv venv
60+
. venv/bin/activate
61+
python -m pip install -U pip setuptools wheel
62+
pip install -U -r requirements_test.txt
63+
64+
- name: Download outputs
65+
uses: actions/github-script@v6
66+
with:
67+
script: |
68+
// Download workflow pylint output
69+
const fs = require('fs');
70+
const artifacts_workflow = await github.rest.actions.listWorkflowRunArtifacts({
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
run_id: ${{ github.event.workflow_run.id }},
74+
});
75+
76+
// Get 'main' output
77+
const [matchArtifactWorkflowMain] = artifacts_workflow.data.artifacts.filter((artifact) =>
78+
artifact.name == "primer_output_main");
79+
const downloadOne = await github.rest.actions.downloadArtifact({
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
artifact_id: matchArtifactWorkflowMain.id,
83+
archive_format: "zip",
84+
});
85+
fs.writeFileSync("primer_main_output.zip", Buffer.from(downloadOne.data));
86+
87+
// Get PR output
88+
const [matchArtifactWorkflowPR] = artifacts_workflow.data.artifacts.filter((artifact) =>
89+
artifact.name == "primer_output_pr");
90+
const downloadTwo = await github.rest.actions.downloadArtifact({
91+
owner: context.repo.owner,
92+
repo: context.repo.repo,
93+
artifact_id: matchArtifactWorkflowPR.id,
94+
archive_format: "zip",
95+
});
96+
fs.writeFileSync("primer_pr_output.zip", Buffer.from(downloadTwo.data));
97+
98+
// Get PR number
99+
const [matchArtifactWorkflowNumber] = artifacts_workflow.data.artifacts.filter((artifact) =>
100+
artifact.name == "pr_number");
101+
const downloadThree = await github.rest.actions.downloadArtifact({
102+
owner: context.repo.owner,
103+
repo: context.repo.repo,
104+
artifact_id: matchArtifactWorkflowNumber.id,
105+
archive_format: "zip",
106+
});
107+
fs.writeFileSync("primer_pr_number.zip", Buffer.from(downloadThree.data));
108+
- run: unzip primer_main_output.zip
109+
- run: unzip primer_pr_output.zip
110+
- run: unzip primer_pr_number.zip
111+
- name: Compare outputs
112+
run: |
113+
. venv/bin/activate
114+
python tests/primer/primer_tool.py compare --base-file=output_main.txt --new-file=output_pr.txt
115+
- name: Post comment
116+
id: post-comment
117+
uses: actions/github-script@v6
118+
with:
119+
github-token: ${{ secrets.GITHUB_TOKEN }}
120+
script: |
121+
const fs = require('fs')
122+
const comment = fs.readFileSync('tests/.pylint_primer_tests/comment.txt', { encoding: 'utf8' })
123+
console.log("Comment to post:")
124+
console.log(comment)
125+
const prNumber = parseInt(fs.readFileSync("pr_number.txt", { encoding: "utf8" }))
126+
await github.rest.issues.createComment({
127+
issue_number: prNumber,
128+
owner: context.repo.owner,
129+
repo: context.repo.repo,
130+
body: comment
131+
})
132+
return prNumber
133+
- name: Hide old comments
134+
# Taken from mypy primer
135+
# v0.3.0
136+
uses: kanga333/comment-hider@bbdf5b562fbec24e6f60572d8f712017428b92e0
137+
with:
138+
github_token: ${{ secrets.GITHUB_TOKEN }}
139+
leave_visible: 1
140+
issue_number: ${{ steps.post-comment.outputs.result }}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Most of this is inspired by the mypy primer
2+
# See: https://github.com/hauntsaninja/mypy_primer
3+
# This is the primer job that runs on the default 'main' branch
4+
# It is also responsible for caching the packages to prime on
5+
6+
name: Primer / Main
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
paths-ignore:
13+
- doc/data/messages/**
14+
15+
env:
16+
CACHE_VERSION: 1
17+
18+
jobs:
19+
run-primer:
20+
name: Run / ${{ matrix.python-version }}
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 45
23+
strategy:
24+
matrix:
25+
python-version: ["3.8"]
26+
steps:
27+
- name: Check out code from GitHub
28+
uses: actions/[email protected]
29+
- name: Set up Python ${{ matrix.python-version }}
30+
id: python
31+
uses: actions/[email protected]
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Get latest astroid commit
36+
id: get-astroid-sha
37+
run: |
38+
curl https://api.github.com/repos/PyCQA/astroid/commits |
39+
python -c "import json, sys; print(json.load(sys.stdin)[0]['sha'])" > astroid_sha.txt
40+
41+
# Restore cached Python environment
42+
- name: Generate partial Python venv restore key
43+
id: generate-python-key
44+
run: >-
45+
echo "::set-output name=key::venv-${{ env.CACHE_VERSION }}-${{
46+
hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt',
47+
'astroid_sha.txt') }}"
48+
- name: Restore Python virtual environment
49+
id: cache-venv
50+
uses: actions/[email protected]
51+
with:
52+
path: venv
53+
key: >-
54+
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
55+
steps.generate-python-key.outputs.key }}
56+
restore-keys: |
57+
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ env.CACHE_VERSION }}-
58+
- name: Create Python virtual environment
59+
if: steps.cache-venv.outputs.cache-hit != 'true'
60+
run: |
61+
python -m venv venv
62+
. venv/bin/activate
63+
python -m pip install -U pip setuptools wheel
64+
pip install -U -r requirements_test.txt
65+
# Use bleeding-edge astroid
66+
pip install git+https://github.com/PyCQA/astroid.git
67+
68+
# Cache primer packages
69+
- name: Get commit string
70+
id: commitstring
71+
run: |
72+
. venv/bin/activate
73+
python tests/primer/primer_tool.py prepare --make-commit-string
74+
output=$(python tests/primer/primer_tool.py prepare --read-commit-string)
75+
echo "::set-output name=commitstring::$output"
76+
- name: Restore projects cache
77+
id: cache-projects
78+
uses: actions/cache@v3
79+
with:
80+
path: tests/.pylint_primer_tests/
81+
key: >-
82+
${{ runner.os }}-${{ matrix.python-version }}-${{
83+
steps.commitstring.outputs.commitstring }}-primer
84+
- name: Regenerate cache
85+
run: |
86+
. venv/bin/activate
87+
python tests/primer/primer_tool.py prepare --clone
88+
- name: Upload output diff
89+
uses: actions/upload-artifact@v3
90+
with:
91+
name: primer_commitstring
92+
path: tests/.pylint_primer_tests/commit_string.txt
93+
94+
# Run primer
95+
- name: Run pylint primer
96+
run: |
97+
. venv/bin/activate
98+
pip install -e .
99+
python tests/primer/primer_tool.py run --type=main
100+
- name: Upload output
101+
uses: actions/upload-artifact@v3
102+
with:
103+
name: primer_output
104+
path: tests/.pylint_primer_tests/output_main.txt

0 commit comments

Comments
 (0)