Skip to content

Commit 385b81b

Browse files
authored
Upgrade to repo-config v0.6.1 (#620)
The new repo-config version brings a few important changes: * Dependabot grouping * Replace `darglint` with `pydoclint` * Introduction of `flake8` basic checks * Start checking docstrings and `flake8` basic checks in tests and benchmarks Becuase of this, this PR is very big, as it needs to fix a lot of issues detected by `pydoclint` and `flake8`. The first commits, up to **Add `mypy` configuration to `pyproject.toml`** deal with the upgrade of repo-config templates. The rest of the commits are documentation fixes (first from `pydoclint` and then from `pydocstyle`) plus some other `flake8` fixes, usually in that order.
2 parents 3b944e4 + 5e879be commit 385b81b

File tree

63 files changed

+371
-247
lines changed

Some content is hidden

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

63 files changed

+371
-247
lines changed

.github/dependabot.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ updates:
33
- package-ecosystem: "pip"
44
directory: "/"
55
schedule:
6-
interval: "daily"
6+
interval: "weekly"
77
time: "07:00"
88
labels:
99
- "part:tooling"
@@ -13,11 +13,28 @@ updates:
1313
versioning-strategy: auto
1414
# Allow up to 10 open pull requests for updates to dependency versions
1515
open-pull-requests-limit: 10
16+
# We group production and development ("optional" in the context of
17+
# pyproject.toml) dependency updates when they are patch and minor updates,
18+
# so we end up with less PRs being generated.
19+
# Major updates are still managed, but they'll create one PR per
20+
# dependency, as major updates are expected to be breaking, it is better to
21+
# manage them individually.
22+
groups:
23+
required:
24+
dependency-type: "production"
25+
update-types:
26+
- "minor"
27+
- "patch"
28+
optional:
29+
dependency-type: "development"
30+
update-types:
31+
- "minor"
32+
- "patch"
1633

1734
- package-ecosystem: "github-actions"
1835
directory: "/"
1936
schedule:
20-
interval: "daily"
37+
interval: "weekly"
2138
time: "06:00"
2239
labels:
2340
- "part:tooling"

.github/workflows/ci.yaml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,17 @@ jobs:
3232
- ubuntu-20.04
3333
python:
3434
- "3.11"
35+
nox-session:
36+
# To speed things up a bit we use the special ci_checks_max session
37+
# that uses the same venv to run multiple linting sessions
38+
- "ci_checks_max"
39+
- "pytest_min"
3540
runs-on: ${{ matrix.os }}
3641

3742
steps:
43+
- name: Print environment (debug)
44+
run: env
45+
3846
- name: Fetch sources
3947
uses: actions/checkout@v3
4048
with:
@@ -50,11 +58,25 @@ jobs:
5058
run: |
5159
python -m pip install --upgrade pip
5260
python -m pip install -e .[dev-noxfile]
61+
pip freeze
62+
63+
- name: Create nox venv
64+
env:
65+
NOX_SESSION: ${{ matrix.nox-session }}
66+
run: nox --install-only -e "$NOX_SESSION"
67+
68+
- name: Print pip freeze for nox venv (debug)
69+
env:
70+
NOX_SESSION: ${{ matrix.nox-session }}
71+
run: |
72+
. ".nox/$NOX_SESSION/bin/activate"
73+
pip freeze
74+
deactivate
5375
5476
- name: Run nox
55-
# To speed things up a bit we use the special ci_checks_max session
56-
# that uses the same venv to run multiple linting sessions
57-
run: nox -e ci_checks_max pytest_min
77+
env:
78+
NOX_SESSION: ${{ matrix.nox-session }}
79+
run: nox -R -e "$NOX_SESSION"
5880
timeout-minutes: 10
5981

6082
build:
@@ -76,6 +98,7 @@ jobs:
7698
run: |
7799
python -m pip install -U pip
78100
python -m pip install -U build
101+
pip freeze
79102
80103
- name: Build the source and binary distribution
81104
run: python -m build
@@ -135,6 +158,7 @@ jobs:
135158
run: |
136159
python -m pip install -U pip
137160
python -m pip install .[dev-mkdocs]
161+
pip freeze
138162
139163
- name: Generate the documentation
140164
env:
@@ -217,6 +241,7 @@ jobs:
217241
run: |
218242
python -m pip install -U pip
219243
python -m pip install .[dev-mkdocs]
244+
pip freeze
220245
221246
- name: Fetch the gh-pages branch
222247
if: steps.mike-metadata.outputs.version

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
exclude .cookiecutter-replay.json
2-
exclude .darglint
32
exclude .editorconfig
43
exclude .gitignore
54
exclude CODEOWNERS

benchmarks/power_distribution/power_distributor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ async def send_requests(batteries: Set[int], request_num: int) -> List[Result]:
3636
"""Send requests to the PowerDistributingActor and wait for the response.
3737
3838
Args:
39-
user: user that should send request
4039
batteries: set of batteries where the power should be set
4140
request_num: number of requests that should be send
4241

benchmarks/timeseries/benchmark_ringbuffer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def test_days(days: int, buffer: OrderedRingBuffer[Any]) -> None:
3939
basetime = datetime(2022, 1, 1, tzinfo=timezone.utc)
4040

4141
for day in range(days):
42-
# pylint: disable=unused-variable
43-
minutes = buffer.window(
42+
_ = buffer.window(
4443
basetime + timedelta(days=day), basetime + timedelta(days=day + 1)
4544
)
4645

benchmarks/timeseries/periodic_feature_extractor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def _calculate_avg_window(
6464
feature_extractor: The instance of the PeriodicFeatureExtractor to use.
6565
window: The window to calculate the average over.
6666
window_size: The size of the window to calculate the average over.
67-
weights: The weights to use for the average calculation.
6867
6968
Returns:
7069
The averaged window.
@@ -113,6 +112,7 @@ def _num_windows(
113112
Args:
114113
window: The buffer that is used for the average calculation.
115114
window_size: The size of the window in samples.
115+
period: The distance between two succeeding intervals in samples.
116116
117117
Returns:
118118
The number of windows that are fully contained in the MovingWindow.
@@ -168,7 +168,7 @@ def run_avg_np(
168168
The return value is discarded such that it can be used by timit.
169169
170170
Args:
171-
a: The array containing all data.
171+
array: The array containing all data.
172172
window_size: The size of the window.
173173
feature_extractor: An instance of the PeriodicFeatureExtractor.
174174
"""
@@ -185,7 +185,7 @@ def run_avg_py(
185185
The return value is discarded such that it can be used by timit.
186186
187187
Args:
188-
a: The array containing all data.
188+
array: The array containing all data.
189189
window_size: The size of the window.
190190
feature_extractor: An instance of the PeriodicFeatureExtractor.
191191
"""

benchmarks/timeseries/ringbuffer_serialization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def benchmark_serialization(
4545
Args:
4646
ringbuffer: Ringbuffer to benchmark to serialize.
4747
iterations: amount of iterations to run.
48+
49+
Returns:
50+
Average time to dump and load the ringbuffer.
4851
"""
4952
total = 0.0
5053
for _ in range(iterations):

pyproject.toml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
requires = [
66
"setuptools == 68.1.0",
77
"setuptools_scm[toml] == 7.1.0",
8-
"frequenz-repo-config[lib] == 0.5.2",
8+
"frequenz-repo-config[lib] == 0.6.1",
99
]
1010
build-backend = "setuptools.build_meta"
1111

@@ -49,10 +49,12 @@ name = "Frequenz Energy-as-a-Service GmbH"
4949
5050

5151
[project.optional-dependencies]
52-
dev-docstrings = [
52+
dev-flake8 = [
53+
"flake8 == 6.1.0",
54+
"flake8-docstrings == 1.7.0",
55+
"flake8-pyproject == 1.2.3", # For reading the flake8 config from pyproject.toml
56+
"pydoclint == 0.3.1",
5357
"pydocstyle == 6.3.0",
54-
"darglint == 1.8.1",
55-
"tomli == 2.0.1", # Needed by pydocstyle to read pyproject.toml
5658
]
5759
dev-examples = ["polars == 0.18.15"]
5860
dev-formatting = ["black == 23.7.0", "isort == 5.12.0"]
@@ -63,35 +65,40 @@ dev-mkdocs = [
6365
"mkdocs-material == 9.2.5",
6466
"mkdocs-section-index == 0.3.5",
6567
"mkdocstrings[python] == 0.22.0",
66-
"frequenz-repo-config[lib] == 0.5.2",
68+
"frequenz-repo-config[lib] == 0.6.1",
6769
]
6870
dev-mypy = [
6971
"mypy == 1.5.1",
70-
"grpc-stubs == 1.24.12", # This dependency introduces breaking changes in patch releases
72+
"grpc-stubs == 1.24.12", # This dependency introduces breaking changes in patch releases
73+
"types-Markdown == 3.4.2.10",
74+
"types-PyYAML == 6.0.12.11",
75+
"types-Pygments == 2.16.0.0",
76+
"types-colorama == 0.4.15.12",
7177
"types-protobuf == 4.24.0.1",
78+
"types-python-dateutil == 2.8.19.14",
79+
"types-pytz == 2023.3.0.1",
80+
"types-setuptools == 68.1.0.0",
7281
# For checking the noxfile, docs/ script, and tests
7382
"frequenz-sdk[dev-mkdocs,dev-noxfile,dev-pytest]",
7483
]
75-
dev-noxfile = ["nox == 2023.4.22", "frequenz-repo-config[lib] == 0.5.2"]
84+
dev-noxfile = ["nox == 2023.4.22", "frequenz-repo-config[lib] == 0.6.1"]
7685
dev-pylint = [
7786
"pylint == 2.17.5",
7887
# For checking the noxfile, docs/ script, and tests
7988
"frequenz-sdk[dev-mkdocs,dev-noxfile,dev-pytest]",
8089
]
8190
dev-pytest = [
8291
"pytest == 7.4.0",
83-
"frequenz-repo-config[extra-lint-examples] == 0.5.2",
92+
"frequenz-repo-config[extra-lint-examples] == 0.6.1",
8493
"pytest-mock == 3.11.1",
8594
"pytest-asyncio == 0.21.1",
8695
"time-machine == 2.12.0",
8796
"async-solipsism == 0.5",
8897
# For checking docstring code examples
89-
"sybil == 5.0.3",
90-
"pylint == 2.17.5",
9198
"frequenz-sdk[dev-examples]",
9299
]
93100
dev = [
94-
"frequenz-sdk[dev-mkdocs,dev-docstrings,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
101+
"frequenz-sdk[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
95102
]
96103

97104
[project.urls]
@@ -110,6 +117,23 @@ profile = "black"
110117
line_length = 88
111118
src_paths = ["benchmarks", "examples", "src", "tests"]
112119

120+
[tool.flake8]
121+
# We give some flexibility to go over 88, there are cases like long URLs or
122+
# code in documenation that have extra indentation. Black will still take care
123+
# of making everything that can be 88 wide, 88 wide.
124+
max-line-length = 100
125+
extend-ignore = [
126+
"E203", # Whitespace before ':' (conflicts with black)
127+
"W503", # Line break before binary operator (conflicts with black)
128+
]
129+
# pydoclint options
130+
style = "google"
131+
allow-init-docstring = true
132+
arg-type-hints-in-docstring = false
133+
arg-type-hints-in-signature = true
134+
check-return-types = false
135+
check-yield-types = false
136+
113137
[tool.pylint.similarities]
114138
ignore-comments = ['yes']
115139
ignore-docstrings = ['yes']
@@ -125,6 +149,10 @@ disable = [
125149
# pylint's unsubscriptable check is buggy and is not needed because
126150
# it is a type-check, for which we already have mypy.
127151
"unsubscriptable-object",
152+
# Checked by flake8
153+
"line-too-long",
154+
"unused-variable",
155+
"unnecessary-lambda-assignment",
128156
]
129157

130158
[tool.pylint.design]

src/frequenz/sdk/actor/_run_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async def run(*actors: Actor) -> None:
1616
"""Await the completion of all actors.
1717
1818
Args:
19-
actors: the actors to be awaited.
19+
*actors: the actors to be awaited.
2020
"""
2121
_logger.info("Starting %s actor(s)...", len(actors))
2222

src/frequenz/sdk/actor/power_distributing/_battery_pool_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class BatteryPoolStatus:
7070
Send set of working and uncertain batteries, when the any battery change status.
7171
"""
7272

73-
def __init__(
73+
def __init__( # noqa: DOC502 (RuntimeError is raised indirectly by BatteryStatus)
7474
self,
7575
battery_ids: Set[int],
7676
battery_status_sender: Sender[BatteryStatus],

0 commit comments

Comments
 (0)