Skip to content

Commit 706d174

Browse files
authored
Merge pull request #1186 from dimaqq/chore-ruff
#1186 What this PR does In short, we'll be relying on ruff via pre-commit as opposed to flake8 via tox. - switches from flake8 to ruff - reformats the source code - reformats the docstrings where safe, conservatively - resolves ruff complaints where that's straightforward - silences with a `FIXME` where public API could break or code change is not obvious or where too much manual work is required, those can be fixed in separate PRs - updates the CI and docs for the above Check list - [x] pre-commit config - [x] ruff over the codebase - [x] resolve or silence errors - [x] kill old linter and github actions - [x] GitHub actions to check pre-commit - [x] run pre-commit after codegen - [x] add to docs
2 parents 3436c2d + f5b93e7 commit 706d174

205 files changed

Lines changed: 41601 additions & 27850 deletions

File tree

Some content is hidden

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

.github/ISSUE_TEMPLATE/BugReport.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ body:
5353
Please provide a simplified reproducer, and if it's possible please refrain from providing a 'clone this repository and run the integration tests to see the problem' type of a reproducer. Thanks!"
5454
render: python
5555
validations:
56-
required: true
56+
required: true

.github/ISSUE_TEMPLATE/FeatureRequest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ body:
3333
description: "Please provide valid Python code that you'd like to be able to run with this new feature: "
3434
render: python
3535
validations:
36-
required: true
36+
required: true

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ All CI tests need to pass.
2323

2424
#### Notes & Discussion
2525

26-
*\<Additional notes for the reviewers if needed. Please delete section if not applicable.\>*
26+
*\<Additional notes for the reviewers if needed. Please delete section if not applicable.\>*

.github/workflows/pre-commit.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: pre-commit
3+
4+
on:
5+
pull_request:
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.13"
17+
- uses: pre-commit/action@v3.0.1

.github/workflows/static-analysis.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717
- uses: wagoid/commitlint-github-action@v6
18-

.github/workflows/test.yaml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,6 @@ concurrency:
77
cancel-in-progress: true
88

99
jobs:
10-
lint:
11-
name: Linter
12-
runs-on: ubuntu-latest
13-
strategy:
14-
matrix:
15-
python:
16-
- "3.9"
17-
- "3.10"
18-
steps:
19-
- name: Check out code
20-
uses: actions/checkout@v4
21-
- name: Setup Python
22-
uses: actions/setup-python@v5
23-
with:
24-
python-version: ${{ matrix.python }}
25-
- name: Install dependencies
26-
run: pip install tox
27-
- name: Run linter
28-
run: |
29-
tox -e lint
30-
./scripts/copyright.sh
31-
3210
build-test:
3311
name: Build test
3412
runs-on: ubuntu-latest
@@ -37,14 +15,12 @@ jobs:
3715
python:
3816
- "3.10"
3917
steps:
40-
- name: Check out code
41-
uses: actions/checkout@v4
42-
- name: Setup Python
43-
uses: actions/setup-python@v5
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
4420
with:
4521
python-version: ${{ matrix.python }}
46-
- name: Run build test target
47-
run: |
22+
- uses: astral-sh/setup-uv@v3.2.2
23+
- run: |
4824
make build-test
4925
5026
validate:
@@ -67,7 +43,6 @@ jobs:
6743
run: tox -e validate
6844

6945
unit-tests:
70-
needs: lint
7146
name: Unit tests
7247
runs-on: ubuntu-latest
7348
strategy:
@@ -93,7 +68,7 @@ jobs:
9368

9469
integration:
9570
name: Integration
96-
needs: [lint, unit-tests]
71+
needs: [unit-tests]
9772
timeout-minutes: 150
9873
runs-on: ubuntu-latest
9974
strategy:
@@ -161,7 +136,7 @@ jobs:
161136

162137
integration-quarantine:
163138
name: Quarantined Integration Tests
164-
needs: [lint, unit-tests]
139+
needs: [unit-tests]
165140
timeout-minutes: 150
166141
runs-on: ubuntu-latest
167142
strategy:

.github/workflows/test_candidate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
else
4343
echo "Candidate $candidate has to be tested"
4444
next_test="$candidate"
45-
fi
45+
fi
4646
fi
4747
echo "next-test=$next_test" >> $GITHUB_ENV
4848
echo "$next_test" > ~/juju-last-candidate-version

.github/workflows/test_edge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
else
4343
echo "Edge $edge has to be tested"
4444
next_test="$edge"
45-
fi
45+
fi
4646
fi
4747
echo "next-test=$next_test" >> $GITHUB_ENV
4848
echo "$next_test" > ~/juju-last-edge-version

.pre-commit-config.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: check-added-large-files
6+
exclude: |
7+
(?x) # Verbose mode
8+
^juju/client/schemas-juju-.*[.]json$ |
9+
^tests/.*[.]charm$ |
10+
^examples/.*[.]charm$
11+
- id: check-ast
12+
- id: check-case-conflict
13+
- id: check-executables-have-shebangs
14+
- id: check-shebang-scripts-are-executable
15+
- id: check-merge-conflict
16+
- id: check-symlinks
17+
- id: check-json
18+
- id: check-yaml
19+
# Overlays deliberately comprise multiple YAML documents per file
20+
exclude: "^tests/integration/bundle/test-overlays/.*multi.*yaml$"
21+
- id: check-toml
22+
- id: mixed-line-ending
23+
- id: end-of-file-fixer
24+
exclude: "^juju/client/schemas-juju-.*[.]json$"
25+
- id: trailing-whitespace
26+
- id: detect-private-key
27+
exclude: "^tests/.*$"
28+
29+
- repo: https://github.com/astral-sh/ruff-pre-commit
30+
rev: v0.7.3
31+
hooks:
32+
- id: ruff
33+
args: [ --preview, --fix ]
34+
- id: ruff-format
35+
args: [ --preview ]
36+
37+
- repo: https://github.com/codespell-project/codespell
38+
rev: v2.3.0
39+
hooks:
40+
- id: codespell
41+
additional_dependencies:
42+
- tomli
43+
exclude: "^juju/client/schemas-juju-.*[.]json$"
44+
45+
ci:
46+
autofix_prs: false

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ build:
1010
python: "3.10"
1111

1212
sphinx:
13-
configuration: docs/conf.py
13+
configuration: docs/conf.py

0 commit comments

Comments
 (0)