Skip to content

Commit bedf879

Browse files
committed
refactor: Write comments, not docstrings in internal modules/scripts
1 parent fd500cc commit bedf879

7 files changed

+17
-46
lines changed

project/config/ruff.toml.jinja

+9-2
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,24 @@ ignore = [
4747
]
4848

4949
[lint.per-file-ignores]
50-
"src/*/cli.py" = [
50+
"src/**/cli.py" = [
5151
"T201", # Print statement
5252
]
5353
"src/*/debug.py" = [
5454
"T201", # Print statement
5555
]
56+
"!src/*/*.py" = [
57+
"D100", # Missing docstring in public module
58+
]
59+
"!src/**.py" = [
60+
"D101", # Missing docstring in public class
61+
"D103", # Missing docstring in public function
62+
]
5663
"scripts/*.py" = [
5764
"INP001", # File is part of an implicit namespace package
5865
"T201", # Print statement
5966
]
60-
"tests/*.py" = [
67+
"tests/**.py" = [
6168
"ARG005", # Unused lambda argument
6269
"FBT001", # Boolean positional arg in function definition
6370
"PLR2004", # Magic value used in comparison

project/duties.py.jinja

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ PTY = not WINDOWS and not CI
2626
MULTIRUN = os.environ.get("MULTIRUN", "0") == "1"
2727

2828

29-
def pyprefix(title: str) -> str: # noqa: D103
29+
def pyprefix(title: str) -> str:
3030
if MULTIRUN:
3131
prefix = f"(python{sys.version_info.major}.{sys.version_info.minor})"
3232
return f"{prefix:14}{title}"
3333
return title
3434

3535

3636
@contextmanager
37-
def material_insiders() -> Iterator[bool]: # noqa: D103
37+
def material_insiders() -> Iterator[bool]:
3838
if "+insiders" in pkgversion("mkdocs-material"):
3939
os.environ["MATERIAL_INSIDERS"] = "true"
4040
try:

project/scripts/gen_api_ref.py.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Generate the code reference pages and navigation."""
1+
# Generate the API reference pages and navigation.
22

33
from pathlib import Path
44

project/scripts/gen_credits.py.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Script to generate the project's credits."""
1+
# Script to generate the project's credits.
22

33
from __future__ import annotations
44

project/scripts/get_version.py.jinja

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Get current project version from Git tags or changelog."""
1+
# Get current project version from Git tags or changelog.
22

33
import re
44
from contextlib import suppress
@@ -13,7 +13,6 @@ _default_scm_version = SCMVersion(Version("0.0.0"), None, False, None, None) #
1313

1414

1515
def get_version() -> str:
16-
"""Get current project version from Git tags or changelog."""
1716
scm_version = get_version_from_scm(_root) or _default_scm_version
1817
if scm_version.version <= Version("0.1"): # Missing Git tags?
1918
with suppress(OSError, StopIteration): # noqa: SIM117

project/scripts/make.py.jinja

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/usr/bin/env python3
2-
"""Management commands."""
3-
42
from __future__ import annotations
53

64
import os

project/scripts/{% if insiders %}insiders.py{% endif %}.jinja

+3-36
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Functions related to Insiders funding goals."""
1+
# Functions related to Insiders funding goals.
22

33
from __future__ import annotations
44

@@ -23,7 +23,7 @@ if TYPE_CHECKING:
2323
logger = logging.getLogger(f"mkdocs.logs.{__name__}")
2424

2525

26-
def human_readable_amount(amount: int) -> str: # noqa: D103
26+
def human_readable_amount(amount: int) -> str:
2727
str_amount = str(amount)
2828
if len(str_amount) >= 4: # noqa: PLR2004
2929
return f"{str_amount[: len(str_amount) - 3]},{str_amount[-3:]}"
@@ -32,16 +32,12 @@ def human_readable_amount(amount: int) -> str: # noqa: D103
3232

3333
@dataclass
3434
class Project:
35-
"""Class representing an Insiders project."""
36-
3735
name: str
3836
url: str
3937

4038

4139
@dataclass
4240
class Feature:
43-
"""Class representing an Insiders feature."""
44-
4541
name: str
4642
ref: str | None
4743
since: date | None
@@ -68,8 +64,6 @@ class Feature:
6864

6965
@dataclass
7066
class Goal:
71-
"""Class representing an Insiders goal."""
72-
7367
name: str
7468
amount: int
7569
features: list[Feature]
@@ -96,16 +90,6 @@ class Goal:
9690

9791

9892
def load_goals(data: str, funding: int = 0, project: Project | None = None) -> dict[int, Goal]:
99-
"""Load goals from JSON data.
100-
101-
Parameters:
102-
data: The JSON data.
103-
funding: The current total funding, per month.
104-
origin: The origin of the data (URL).
105-
106-
Returns:
107-
A dictionaries of goals, keys being their target monthly amount.
108-
"""
10993
goals_data = yaml.safe_load(data)["goals"]
11094
return {
11195
amount: Goal(
@@ -153,15 +137,6 @@ def _load_goals(source: str | tuple[str, str, str], funding: int = 0) -> dict[in
153137

154138

155139
def funding_goals(source: str | list[str | tuple[str, str, str]], funding: int = 0) -> dict[int, Goal]:
156-
"""Load funding goals from a given data source.
157-
158-
Parameters:
159-
source: The data source (local file path or URL).
160-
funding: The current total funding, per month.
161-
162-
Returns:
163-
A dictionaries of goals, keys being their target monthly amount.
164-
"""
165140
if isinstance(source, str):
166141
return _load_goals_from_disk(source, funding)
167142
goals = {}
@@ -176,18 +151,10 @@ def funding_goals(source: str | list[str | tuple[str, str, str]], funding: int =
176151

177152

178153
def feature_list(goals: Iterable[Goal]) -> list[Feature]:
179-
"""Extract feature list from funding goals.
180-
181-
Parameters:
182-
goals: A list of funding goals.
183-
184-
Returns:
185-
A list of features.
186-
"""
187154
return list(chain.from_iterable(goal.features for goal in goals))
188155

189156

190-
def load_json(url: str) -> str | list | dict: # noqa: D103
157+
def load_json(url: str) -> str | list | dict:
191158
with urlopen(url) as response: # noqa: S310
192159
return json.loads(response.read().decode())
193160

0 commit comments

Comments
 (0)