Skip to content

Commit cee71b6

Browse files
authored
docs: Update changelog to address mdformat issues (#137)
* docs: Update changelog to address mdformat issues. Also added pylint as an additional check for python coding standards and errors. * ci: Skip running pylint in pre-commit.ci since it isn't available
1 parent ed405fe commit cee71b6

File tree

10 files changed

+119
-32
lines changed

10 files changed

+119
-32
lines changed

.pre-commit-config.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ default_stages: [pre-commit]
44
ci:
55
autofix_prs: false
66
autoupdate_schedule: weekly
7-
skip: [check-poetry, pyright, poetry-audit, markdown-link-check]
7+
autoupdate_commit_msg: 'chore(pre-commit-deps): pre-commit autoupdate'
8+
skip:
9+
- check-poetry
10+
- pylint
11+
- pyright
12+
- poetry-audit
13+
- markdown-link-check
814
repos:
915
- repo: https://github.com/pre-commit/pre-commit-hooks
1016
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
@@ -60,7 +66,7 @@ repos:
6066
hooks:
6167
- id: blacken-docs
6268
files: \.(rst|md|markdown|tex)$
63-
additional_dependencies: [black==24.4.2] # This may need to be updated/removed in the future once ruff supports formatting Python code blocks in markdown
69+
additional_dependencies: [black==24.8.0] # This may need to be updated/removed in the future once ruff supports formatting Python code blocks in markdown
6470
args: [--line-length=100]
6571
- repo: https://github.com/lyz-code/yamlfix
6672
rev: 8072181c0f2eab9f2dd8db2eb3b9556d7cd0bd74 # frozen: 1.17.0
@@ -107,6 +113,13 @@ repos:
107113
- id: toml-sort-fix
108114
- repo: local
109115
hooks:
116+
- id: pylint
117+
name: pylint
118+
entry: pylint
119+
language: system
120+
types: [python]
121+
pass_filenames: true
122+
args: [-sn]
110123
- id: pyright
111124
name: pyright
112125
entry: pyright

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Things to be included in the next release go here.
3838
- chore(python-deps): update dependency pyright to v1.1.382.post1 for dev ([#132](https://github.com/tektronix/python-package-ci-cd/pull/132))
3939
- chore(docker-deps): update python:3.12-alpine docker digest to e75de17 in all dependant actions ([#130](https://github.com/tektronix/python-package-ci-cd/pull/130))
4040
- chore(docker-deps): update python:3.12-alpine docker digest to 6666ea3 in all dependant actions ([#129](https://github.com/tektronix/python-package-ci-cd/pull/129))
41-
- [pre-commit.ci] pre-commit autoupdate ([#117](https://github.com/tektronix/python-package-ci-cd/pull/117))
41+
- chore(pre-commit-deps): pre-commit autoupdate ([#117](https://github.com/tektronix/python-package-ci-cd/pull/117))
4242
- chore(python-deps): update dependency pyright to v1.1.382.post0 for dev ([#125](https://github.com/tektronix/python-package-ci-cd/pull/125))
4343
- chore(python-deps): update dependency pyright to v1.1.382 for dev ([#124](https://github.com/tektronix/python-package-ci-cd/pull/124))
4444
- chore(gh-actions-deps): update github/codeql-action action to v3.26.9 in all dependant reusable workflows ([#123](https://github.com/tektronix/python-package-ci-cd/pull/123))

actions/create_unique_testpypi_version/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def main() -> None:
8787
tomli_w.dump(pyproject_data, file_handle)
8888

8989
# Set the output variable for GitHub Actions
90-
with open(os.environ["GITHUB_OUTPUT"], "a") as github_output_file_handle: # noqa: PTH123
90+
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as github_output_file_handle: # noqa: PTH123
9191
github_output_file_handle.write(f"new-version={updated_version}\n")
9292

9393

actions/find_unreleased_changelog_items/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_commit_messages(since_tag: str | None = None) -> list[str]:
6363
return run_cmd_in_subprocess(f"git log {range_spec} --pretty=format:%s").splitlines()
6464

6565

66-
def main() -> None:
66+
def main() -> None: # pylint: disable=too-many-locals
6767
"""Check for entries in the Unreleased section of the CHANGELOG.md file.
6868
6969
Raises:
@@ -137,7 +137,7 @@ def main() -> None:
137137
print(
138138
f"\nAdding the following contents to the GitHub Workflow Summary:\n\n{summary_contents}"
139139
)
140-
with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as summary_file: # noqa: PTH123
140+
with open(os.environ["GITHUB_STEP_SUMMARY"], "a", encoding="utf-8") as summary_file: # noqa: PTH123
141141
summary_file.write(summary_contents)
142142

143143

pyproject.toml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ poetry-audit-plugin = "^0.4.0"
5454
poetry-plugin-export = "1.8.0"
5555
poetry-pre-commit-plugin = "^0.1.2"
5656
pre-commit = "3.8.0"
57+
pylint = "3.3.1"
5758
pyright = "1.1.383"
5859
tox = "^4.18.0"
5960
tox-gh-actions = "^3.2.0"
@@ -83,6 +84,78 @@ pytest-html = "^4.1.1"
8384
pytest-order = "^1.2.1"
8485
pytest-subprocess = "^1.5.2"
8586

87+
[tool.pylint.main]
88+
fail-under = 10.0
89+
ignore-patterns = [
90+
"^\\.#",
91+
"^\\..*_cache",
92+
"^\\.docs.*",
93+
"^\\.env.*",
94+
"^\\.idea",
95+
"^\\.results.*",
96+
"^\\.tox",
97+
"^\\.venv.*",
98+
"^\\.vscode",
99+
"^temp_.*\\..*"
100+
]
101+
init-hook = 'import sys; sys.path.append(".")'
102+
jobs = 0
103+
load-plugins = """
104+
pylint.extensions.check_elif,
105+
pylint.extensions.code_style,
106+
pylint.extensions.comparison_placement,
107+
pylint.extensions.consider_refactoring_into_while_condition,
108+
pylint.extensions.dict_init_mutate,
109+
pylint.extensions.docparams,
110+
pylint.extensions.docstyle,
111+
pylint.extensions.dunder,
112+
pylint.extensions.eq_without_hash,
113+
pylint.extensions.for_any_all,
114+
pylint.extensions.no_self_use,
115+
pylint.extensions.overlapping_exceptions,
116+
pylint.extensions.private_import,
117+
pylint.extensions.set_membership,
118+
pylint.extensions.typing,
119+
pylint.extensions.while_used
120+
"""
121+
recursive = true
122+
123+
[tool.pylint."messages control"]
124+
disable = [
125+
"broad-exception-caught", # caught by ruff
126+
"fixme", # caught by ruff
127+
"global-statement", # caught by ruff
128+
"invalid-name", # caught by ruff
129+
"line-too-long", # caught by ruff
130+
"locally-disabled", # allowed
131+
"missing-class-docstring", # caught by ruff
132+
"missing-module-docstring", # caught by ruff
133+
"no-member", # caught by pyright
134+
"protected-access", # caught by ruff
135+
"raise-missing-from", # caught by ruff
136+
"redefined-builtin", # caught by ruff
137+
"suppressed-message", # allowed
138+
"too-many-arguments", # caught by ruff
139+
"too-many-branches", # caught by ruff
140+
"too-many-statements", # caught by ruff
141+
"too-many-statements", # caught by ruff
142+
"unused-argument", # caught by ruff
143+
"unused-import", # caught by ruff
144+
"use-implicit-booleaness-not-comparison-to-string", # caught by ruff
145+
"wrong-import-order" # caught by ruff
146+
]
147+
enable = ["all"]
148+
149+
[tool.pylint.reports]
150+
# Python expression which should return a score less than or equal to 10. You
151+
# have access to the variables 'fatal', 'error', 'warning', 'refactor',
152+
# 'convention', and 'info' which contain the number of messages in each category,
153+
# as well as 'statement' which is the total number of statements analyzed. This
154+
# score is used by the global evaluation report (RP0004).
155+
evaluation = "max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention + info) / statement) * 10))"
156+
output-format = "text" # colorized could be another option
157+
score = true
158+
86159
[tool.pyright]
87160
ignore = [
88161
"temp_*.py"

tests/test_bump_version_in_files.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test the bump_version_in_files module."""
22

3+
from collections.abc import Generator
34
from pathlib import Path
4-
from typing import Generator
55
from unittest.mock import MagicMock, patch
66

77
import pytest
@@ -10,14 +10,14 @@
1010

1111

1212
@pytest.fixture(autouse=True)
13-
def mock_subprocess_check_call() -> Generator[None, None, None]:
13+
def mock_subprocess_check_call() -> Generator[None]:
1414
"""Mock subprocess.check_call for all tests."""
1515
with patch("subprocess.check_call", MagicMock(return_value=None)):
1616
yield
1717

1818

19-
@pytest.fixture()
20-
def temporary_directory(tmp_path: Path) -> Path:
19+
@pytest.fixture(name="temporary_directory")
20+
def fixture_temporary_directory(tmp_path: Path) -> Path:
2121
"""Create a temporary directory."""
2222
# Create a temporary directory with some files
2323
test_dir = tmp_path / "test_dir"

tests/test_create_unique_testpypi_version.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Generator, TYPE_CHECKING
5+
from typing import TYPE_CHECKING
66
from unittest.mock import MagicMock, patch
77

88
import pytest
@@ -12,6 +12,7 @@
1212
from actions.create_unique_testpypi_version.main import create_new_post_version, main
1313

1414
if TYPE_CHECKING:
15+
from collections.abc import Generator
1516
from pathlib import Path
1617

1718
# Sample data for mocking
@@ -32,8 +33,8 @@ def _mock_environment(monkeypatch: pytest.MonkeyPatch) -> None: # pyright: igno
3233
monkeypatch.setenv("INPUT_PACKAGE-NAME", PACKAGE_NAME)
3334

3435

35-
@pytest.fixture()
36-
def mock_testpypi_server() -> Generator[MagicMock, None, None]:
36+
@pytest.fixture(name="mock_testpypi_server")
37+
def fixture_mock_testpypi_server() -> Generator[MagicMock]:
3738
"""Mock the PyPISimple class and its methods."""
3839
with patch("actions.create_unique_testpypi_version.main.PyPISimple") as mock_pypi_simple:
3940
mock_server = mock_pypi_simple.return_value
@@ -43,8 +44,8 @@ def mock_testpypi_server() -> Generator[MagicMock, None, None]:
4344
yield mock_server
4445

4546

46-
@pytest.fixture()
47-
def mock_pyproject_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
47+
@pytest.fixture(name="mock_pyproject_file")
48+
def fixture_mock_pyproject_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
4849
"""Mock the pyproject.toml file.
4950
5051
Args:
@@ -63,8 +64,8 @@ def mock_pyproject_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path
6364
return pyproject_file
6465

6566

66-
@pytest.fixture()
67-
def mock_github_output_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
67+
@pytest.fixture(name="mock_github_output_file")
68+
def fixture_mock_github_output_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
6869
"""Mock the GitHub output file.
6970
7071
Args:

tests/test_docs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
import sys
77
import time
88

9+
from collections.abc import Generator
910
from importlib.util import find_spec
1011
from pathlib import Path
11-
from typing import Generator
1212

1313
import pytest
1414

1515
REPO_ROOT_DIR = Path(__file__).resolve().parent.parent
1616

1717

1818
@pytest.fixture(name="docs_server")
19-
def fixture_docs_server(site_dir: str) -> Generator[str, None, None]:
19+
def fixture_docs_server(site_dir: str) -> Generator[str]:
2020
"""Serve the documentation site."""
2121
port = f"8{sys.version_info.major}{sys.version_info.minor}"
2222
cmd = [sys.executable, "-m", "http.server", port, "--directory", site_dir]
@@ -49,7 +49,7 @@ def fixture_site_dir(pytestconfig: pytest.Config) -> str:
4949

5050

5151
@pytest.fixture(scope="module", autouse=True)
52-
def _docs_tests_setup() -> Generator[None, None, None]: # pyright: ignore [reportUnusedFunction]
52+
def _docs_tests_setup() -> Generator[None]: # pyright: ignore [reportUnusedFunction]
5353
"""Setup for docs tests.."""
5454
starting_directory = Path.cwd()
5555
try:

tests/test_find_unreleased_changelog_items.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
MOCK_TEMPLATES_FOLDER = "mock_templates"
2323

2424

25-
@pytest.fixture()
26-
def mock_previous_files(tmp_path: Path) -> tuple[Path, Path]:
25+
@pytest.fixture(name="mock_previous_files")
26+
def fixture_mock_previous_files(tmp_path: Path) -> tuple[Path, Path]:
2727
"""Create filepaths in the temporary directory for the template files.
2828
2929
Args:
@@ -40,8 +40,8 @@ def mock_previous_files(tmp_path: Path) -> tuple[Path, Path]:
4040
)
4141

4242

43-
@pytest.fixture()
44-
def mock_changelog_file(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Path:
43+
@pytest.fixture(name="mock_changelog_file")
44+
def fixture_mock_changelog_file(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Path:
4545
"""Mock the pyproject.toml file.
4646
4747
Args:
@@ -63,8 +63,8 @@ def mock_changelog_file(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Path
6363
return mock_path
6464

6565

66-
@pytest.fixture()
67-
def summary_file(tmp_path: Path) -> Path:
66+
@pytest.fixture(name="summary_file")
67+
def fixture_summary_file(tmp_path: Path) -> Path:
6868
"""Create a summary file for the GitHub Actions step.
6969
7070
Args:
@@ -76,8 +76,8 @@ def summary_file(tmp_path: Path) -> Path:
7676
return tmp_path / "github_summary.txt"
7777

7878

79-
@pytest.fixture()
80-
def mock_env_vars(
79+
@pytest.fixture(name="mock_env_vars")
80+
def fixture_mock_env_vars(
8181
tmp_path: Path,
8282
monkeypatch: pytest.MonkeyPatch,
8383
summary_file: Path,

tests/test_update_development_dependencies.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import sys
44

5+
from collections.abc import Generator
56
from pathlib import Path
6-
from typing import Generator
77
from unittest.mock import call, MagicMock, patch
88

99
import pytest
@@ -21,7 +21,7 @@
2121

2222

2323
@pytest.fixture(autouse=True)
24-
def mock_pypi_server() -> Generator[MagicMock, None, None]:
24+
def mock_pypi_server() -> Generator[MagicMock]:
2525
"""Mock the PyPISimple class and its methods."""
2626
with patch("actions.update_development_dependencies.main.PyPISimple") as mock_pypi_simple:
2727
mock_server = mock_pypi_simple.return_value
@@ -31,8 +31,8 @@ def mock_pypi_server() -> Generator[MagicMock, None, None]:
3131
yield mock_server
3232

3333

34-
@pytest.fixture()
35-
def repo_root_dir(
34+
@pytest.fixture(name="repo_root_dir")
35+
def fixture_repo_root_dir(
3636
monkeypatch: pytest.MonkeyPatch,
3737
tmp_path: Path,
3838
) -> Path:

0 commit comments

Comments
 (0)