← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~lgp171188/lpcraft:lint-docstrings-pydocstyle into lpcraft:main

 

Guruprasad has proposed merging ~lgp171188/lpcraft:lint-docstrings-pydocstyle into lpcraft:main.

Commit message:
Add the pydocstyle pre-commit hook to lint the docstrings

Also fix the existing errors reported by the linter.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~lgp171188/lpcraft/+git/lpcraft/+merge/417787
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~lgp171188/lpcraft:lint-docstrings-pydocstyle into lpcraft:main.
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f1856e7..7364193 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -15,12 +15,18 @@ repos:
     rev: 4.0.1
     hooks:
     -   id: flake8
+-   repo: https://github.com/PyCQA/pydocstyle
+    rev: 6.1.1
+    hooks:
+    -   id: pydocstyle
+        additional_dependencies:
+        -   toml==0.10.2
 -   repo: https://github.com/PyCQA/isort
     rev: 5.10.0
     hooks:
     -   id: isort
 -   repo: https://github.com/psf/black
-    rev: 21.10b0
+    rev: 22.3.0
     hooks:
     -   id: black
 -   repo: https://github.com/asottile/setup-cfg-fmt
diff --git a/lpcraft/config.py b/lpcraft/config.py
index b20322e..0777dd3 100644
--- a/lpcraft/config.py
+++ b/lpcraft/config.py
@@ -35,7 +35,7 @@ class ModelConfigDefaults(
 
 
 class OutputDistributeEnum(Enum):
-    """Valid values for `output.distribute.`"""
+    """Valid values for `output.distribute`."""
 
     artifactory = "artifactory"
 
diff --git a/lpcraft/main.py b/lpcraft/main.py
index 8afe421..024b32c 100644
--- a/lpcraft/main.py
+++ b/lpcraft/main.py
@@ -30,7 +30,7 @@ _configure_logger("craft_providers")
 
 
 def main(argv: Optional[List[str]] = None) -> int:
-    """lpcraft runs Launchpad CI jobs."""
+    """`lpcraft` runs Launchpad CI jobs."""
     parser = ArgumentParser(description="Run Launchpad CI jobs.")
     parser.add_argument(
         "--version",
diff --git a/lpcraft/plugin/hookspecs.py b/lpcraft/plugin/hookspecs.py
index cef7971..6b198ea 100644
--- a/lpcraft/plugin/hookspecs.py
+++ b/lpcraft/plugin/hookspecs.py
@@ -19,17 +19,17 @@ hookspec = pluggy.HookspecMarker(NAME)
 
 @hookspec  # type: ignore
 def lpcraft_install_packages() -> list[str]:
-    """system packages to be installed"""
+    """System packages to be installed."""
 
 
 @hookspec  # type: ignore
 def lpcraft_install_snaps() -> list[str]:
-    """snaps to be installed"""
+    """Snaps to be installed."""
 
 
 @hookspec  # type: ignore
 def lpcraft_execute_run() -> str:
-    """command to be executed"""
+    """Command to be executed."""
     # Please note: when both a plugin and the configuration file are
     # providing a `run` command, the one from the configuration file will be
     # used
@@ -37,7 +37,7 @@ def lpcraft_execute_run() -> str:
 
 @hookspec  # type: ignore
 def lpcraft_set_environment() -> dict[str, str | None]:
-    """environment variables to be set"""
+    """Environment variables to be set."""
     # Please note: when there is the same environment variable provided by
     # the plugin and the configuration file, the one in the configuration
     # file will be taken into account
diff --git a/lpcraft/providers/_base.py b/lpcraft/providers/_base.py
index cbfaa64..5721a3b 100644
--- a/lpcraft/providers/_base.py
+++ b/lpcraft/providers/_base.py
@@ -18,7 +18,7 @@ from craft_providers import bases, lxd
 
 
 def sanitize_lxd_instance_name(name: str) -> str:
-    """LXD instance names need to follow a certain pattern
+    """LXD instance names need to follow a certain pattern.
 
     Make sure we follow this pattern:
     https://linuxcontainers.org/lxd/docs/master/instances/
diff --git a/lpcraft/providers/_lxd.py b/lpcraft/providers/_lxd.py
index 51fd266..26c6212 100644
--- a/lpcraft/providers/_lxd.py
+++ b/lpcraft/providers/_lxd.py
@@ -135,8 +135,8 @@ class LXDProvider(Provider):
 
         for name in names:
             if re.match(
-                fr"^lpcraft-{re.escape(project_name)}-{re.escape(inode)}"
-                fr"-.+-.+$",
+                rf"^lpcraft-{re.escape(project_name)}-{re.escape(inode)}"
+                rf"-.+-.+$",
                 name,
             ):
                 emit.trace(f"Deleting container {name!r}.")
diff --git a/lpcraft/providers/tests/test_buildd.py b/lpcraft/providers/tests/test_buildd.py
index e1226e8..0aeda3b 100644
--- a/lpcraft/providers/tests/test_buildd.py
+++ b/lpcraft/providers/tests/test_buildd.py
@@ -10,7 +10,7 @@ from lpcraft.providers._buildd import LPCraftBuilddBaseConfiguration
 
 class TestLPCraftBuilddBaseConfiguration(TestCase):
     def test_compare_configuration_with_other_type(self):
-        """The configuration should only be comparable to its own type"""
+        """The configuration should only be comparable to its own type."""
         with pytest.raises(TypeError):
             "foo" == LPCraftBuilddBaseConfiguration(
                 alias=BuilddBaseAlias.FOCAL,
diff --git a/pyproject.toml b/pyproject.toml
index a8f43fe..f059415 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,2 +1,5 @@
 [tool.black]
 line-length = 79
+
+[tool.pydocstyle]
+add_ignore = "D100,D101,D102,D103,D104,D105,D106,D107"