Merge ~lgp171188/lpci:lint-docstrings-pydocstyle into lpci:main

Proposed by Guruprasad
Status: Merged
Merged at revision: 451bd83317df8ff608a5130daecc670d6344977f
Proposed branch: ~lgp171188/lpci:lint-docstrings-pydocstyle
Merge into: lpci:main
Diff against target: 165 lines (+25/-13)
10 files modified
.pre-commit-config.yaml (+7/-1)
NEWS.rst (+4/-0)
lpcraft/config.py (+1/-1)
lpcraft/main.py (+1/-1)
lpcraft/plugin/hookspecs.py (+4/-4)
lpcraft/providers/_base.py (+1/-1)
lpcraft/providers/_lxd.py (+2/-2)
lpcraft/providers/tests/__init__.py (+1/-2)
lpcraft/providers/tests/test_buildd.py (+1/-1)
setup.cfg (+3/-0)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+417787@code.launchpad.net

Commit message

Add the pydocstyle pre-commit hook to lint the docstrings

Also fix the existing errors reported by the linter.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Looks good with a minor change request.

review: Approve
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

See comment about setup.cfg/pyproject.toml

review: Needs Fixing
Revision history for this message
Guruprasad (lgp171188) :
Revision history for this message
Jürgen Gmach (jugmac00) :
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Looks good!

Could you please add a NEWS entry?

Additionally I think it makes sense to merge this PR after https://code.launchpad.net/~jugmac00/lpcraft/+git/lpcraft/+merge/417965 has been merged.

Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
2index f1856e7..7364193 100644
3--- a/.pre-commit-config.yaml
4+++ b/.pre-commit-config.yaml
5@@ -15,12 +15,18 @@ repos:
6 rev: 4.0.1
7 hooks:
8 - id: flake8
9+- repo: https://github.com/PyCQA/pydocstyle
10+ rev: 6.1.1
11+ hooks:
12+ - id: pydocstyle
13+ additional_dependencies:
14+ - toml==0.10.2
15 - repo: https://github.com/PyCQA/isort
16 rev: 5.10.0
17 hooks:
18 - id: isort
19 - repo: https://github.com/psf/black
20- rev: 21.10b0
21+ rev: 22.3.0
22 hooks:
23 - id: black
24 - repo: https://github.com/asottile/setup-cfg-fmt
25diff --git a/NEWS.rst b/NEWS.rst
26index 5424c96..f4d3db9 100644
27--- a/NEWS.rst
28+++ b/NEWS.rst
29@@ -7,6 +7,10 @@ Version history
30
31 - Sphinx: Turn warnings into errors.
32
33+- pre-commit: Update the ``black`` hook to fix an incompatibility with
34+ ``click==8.1.0``.
35+
36+- pre-commit: Add the ``pydocstyle`` hook to lint the docstrings.
37
38 0.0.5 (2022-03-30)
39 ====================
40diff --git a/lpcraft/config.py b/lpcraft/config.py
41index b20322e..0777dd3 100644
42--- a/lpcraft/config.py
43+++ b/lpcraft/config.py
44@@ -35,7 +35,7 @@ class ModelConfigDefaults(
45
46
47 class OutputDistributeEnum(Enum):
48- """Valid values for `output.distribute.`"""
49+ """Valid values for `output.distribute`."""
50
51 artifactory = "artifactory"
52
53diff --git a/lpcraft/main.py b/lpcraft/main.py
54index 8dc181e..42a68e5 100644
55--- a/lpcraft/main.py
56+++ b/lpcraft/main.py
57@@ -31,7 +31,7 @@ _configure_logger("craft_providers")
58
59
60 def main(argv: Optional[List[str]] = None) -> int:
61- """lpcraft runs Launchpad CI jobs."""
62+ """`lpcraft` runs Launchpad CI jobs."""
63 parser = ArgumentParser(description="Run Launchpad CI jobs.")
64 parser.add_argument(
65 "--version",
66diff --git a/lpcraft/plugin/hookspecs.py b/lpcraft/plugin/hookspecs.py
67index cef7971..6b198ea 100644
68--- a/lpcraft/plugin/hookspecs.py
69+++ b/lpcraft/plugin/hookspecs.py
70@@ -19,17 +19,17 @@ hookspec = pluggy.HookspecMarker(NAME)
71
72 @hookspec # type: ignore
73 def lpcraft_install_packages() -> list[str]:
74- """system packages to be installed"""
75+ """System packages to be installed."""
76
77
78 @hookspec # type: ignore
79 def lpcraft_install_snaps() -> list[str]:
80- """snaps to be installed"""
81+ """Snaps to be installed."""
82
83
84 @hookspec # type: ignore
85 def lpcraft_execute_run() -> str:
86- """command to be executed"""
87+ """Command to be executed."""
88 # Please note: when both a plugin and the configuration file are
89 # providing a `run` command, the one from the configuration file will be
90 # used
91@@ -37,7 +37,7 @@ def lpcraft_execute_run() -> str:
92
93 @hookspec # type: ignore
94 def lpcraft_set_environment() -> dict[str, str | None]:
95- """environment variables to be set"""
96+ """Environment variables to be set."""
97 # Please note: when there is the same environment variable provided by
98 # the plugin and the configuration file, the one in the configuration
99 # file will be taken into account
100diff --git a/lpcraft/providers/_base.py b/lpcraft/providers/_base.py
101index 7650391..6ca78e2 100644
102--- a/lpcraft/providers/_base.py
103+++ b/lpcraft/providers/_base.py
104@@ -19,7 +19,7 @@ from pydantic import StrictStr
105
106
107 def sanitize_lxd_instance_name(name: str) -> str:
108- """LXD instance names need to follow a certain pattern
109+ """LXD instance names need to follow a certain pattern.
110
111 Make sure we follow this pattern:
112 https://linuxcontainers.org/lxd/docs/master/instances/
113diff --git a/lpcraft/providers/_lxd.py b/lpcraft/providers/_lxd.py
114index a8db9e5..aae538e 100644
115--- a/lpcraft/providers/_lxd.py
116+++ b/lpcraft/providers/_lxd.py
117@@ -145,8 +145,8 @@ class LXDProvider(Provider):
118
119 for instance in instances:
120 if re.match(
121- fr"^lpcraft-{re.escape(project_name)}-{re.escape(inode)}"
122- fr"-.+-.+$",
123+ rf"^lpcraft-{re.escape(project_name)}-{re.escape(inode)}"
124+ rf"-.+-.+$",
125 instance,
126 ):
127 emit.trace(f"Deleting container {instance!r}.")
128diff --git a/lpcraft/providers/tests/__init__.py b/lpcraft/providers/tests/__init__.py
129index 835d1b6..e3e9569 100644
130--- a/lpcraft/providers/tests/__init__.py
131+++ b/lpcraft/providers/tests/__init__.py
132@@ -38,8 +38,7 @@ def makeLXDProvider(
133 lxd_project: str = "test-project",
134 lxd_remote: str = "test-remote",
135 ) -> LXDProvider:
136- """A helper function to allow creating a custom LXDProvider for tests."""
137-
138+ """Create a custom LXDProvider for tests."""
139 if lxc is None:
140 lxc = Mock(spec=LXC)
141 lxc.remote_list.return_value = {}
142diff --git a/lpcraft/providers/tests/test_buildd.py b/lpcraft/providers/tests/test_buildd.py
143index e1226e8..0aeda3b 100644
144--- a/lpcraft/providers/tests/test_buildd.py
145+++ b/lpcraft/providers/tests/test_buildd.py
146@@ -10,7 +10,7 @@ from lpcraft.providers._buildd import LPCraftBuilddBaseConfiguration
147
148 class TestLPCraftBuilddBaseConfiguration(TestCase):
149 def test_compare_configuration_with_other_type(self):
150- """The configuration should only be comparable to its own type"""
151+ """The configuration should only be comparable to its own type."""
152 with pytest.raises(TypeError):
153 "foo" == LPCraftBuilddBaseConfiguration(
154 alias=BuilddBaseAlias.FOCAL,
155diff --git a/setup.cfg b/setup.cfg
156index 00e76e3..7b7909a 100644
157--- a/setup.cfg
158+++ b/setup.cfg
159@@ -49,3 +49,6 @@ test =
160 known_first_party = lpcraft
161 line_length = 79
162 profile = black
163+
164+[pydocstyle]
165+add_ignore = D100,D101,D102,D103,D104,D105,D106,D107

Subscribers

People subscribed via source and target branches