Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linting with ruff #926

Merged
merged 1 commit into from
Jun 24, 2024
Merged

Add linting with ruff #926

merged 1 commit into from
Jun 24, 2024

Conversation

ogenstad
Copy link
Collaborator

This PR adds ruff as a linting tool, most of the rules have been activated even though some of the rules might never be relevant for Nornir.

Looking at the activated rules I've also added a number of rules to be ignored for later consideration, a number of these would result in a cleaner code base if fixed.

Another issue is that the change to the complexity rules

[tool.ruff.lint.mccabe]
max-complexity = 12

This was previously set to 10 with pylama, however the rule was also altogether disabled, so it didn't add anything.

For now I didn't disable the pylama checks, but that can be done in a follow up PR.

Also I didn't activate the formatting rules of ruff to replace black. There would be a number of minor formatting changes required such as:

 class FilterObj(Protocol):
-    def __call__(self, host: Host, **kwargs: Any) -> bool:
-        ...
+    def __call__(self, host: Host, **kwargs: Any) -> bool: ...


 class Inventory(object):
@@ -607,13 +595,11 @@
         self,
         filter_obj: Optional[FilterObj] = None,
         filter_func: Optional[FilterObj] = None,
-        **kwargs: Any
+        **kwargs: Any,
     ) -> "Inventory":
         filter_func = filter_obj or filter_func
         if filter_func:
-            filtered = Hosts(
-                {n: h for n, h in self.hosts.items() if filter_func(h, **kwargs)}
-            )
+            filtered = Hosts({n: h for n, h in self.hosts.items() if filter_func(h, **kwargs)})
         else:
             filtered = Hosts(
                 {

Related to #919

@ogenstad ogenstad marked this pull request as ready for review June 19, 2024 19:37
@dbarrosop
Copy link
Contributor

LGTM, i'd suggest different PRs to disable pylama and replace black. Thanks!

@dbarrosop dbarrosop merged commit e8e6e3b into main Jun 24, 2024
26 checks passed
@dbarrosop dbarrosop deleted the ogenstad-ruff branch June 24, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants