-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: applied all suggestions of ruff linter and ruff formater
A ruff config was also added with all the rules that sounded interesting.
- Loading branch information
Showing
10 changed files
with
219 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
line-length = 140 | ||
indent-width = 4 | ||
|
||
target-version = "py311" | ||
|
||
[lint] | ||
select = ["E", "F", "B", "Q", "W", "I", "N", "UP", "ANN", "S", "FBT", "A", "COM", "C4", "DTZ", "EXE", "FA", "ICN", "LOG", "G", "INP", "PIE", "PYI", "PT", "RSE", "RET", "SLF", "SLOT", "SIM", "TID", "INT", "ARG", "PTH", "TD", "ERA", "PL", "TRY", "PERF", "RUF"] | ||
ignore = [ | ||
"G004", # fallback to string formatting syntax while every where f-strings are used, doesn't make sense. | ||
"TRY400", # wtf? we use try-except for NOT printing the full trace ... this would be idiotic to use logging.exception() there :D | ||
"ANN101", # already removed from newer ruff versions | ||
"PERF401", # dont agree with "more readable". Performance difference is negligible | ||
"RET506", # Waiting for https://github.com/astral-sh/ruff/discussions/12468 | ||
"COM812" # disabling suggested by ruff formater. | ||
] | ||
|
||
fixable = ["ALL"] | ||
unfixable = [] | ||
|
||
[lint.pylint] | ||
allow-magic-value-types = ["str", "bytes", "float", "int"] | ||
|
||
[lint.pep8-naming] | ||
classmethod-decorators = ["field_validator", "model_validator"] | ||
|
||
[format] | ||
quote-style = "double" | ||
indent-style = "space" | ||
skip-magic-trailing-comma = false | ||
line-ending = "lf" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class NotAllowedValueError(Exception): | ||
def __init__(self, value: any, allowed_values: list[any]) -> None: | ||
self.value = value | ||
self.allowed_values = allowed_values | ||
|
||
def __str__(self) -> str: | ||
return f"Value '{self.value}' is not allowed. Allowed values are: {', '.join(self.allowed_values)}." | ||
|
||
|
||
class UnknownLogLevelError(Exception): | ||
def __init__(self, value: any, allowed_values: list) -> None: | ||
self.value = value | ||
self.allowed_values = allowed_values | ||
|
||
def __str__(self) -> str: | ||
return f"Log level '{self.value}' is unknown. Allowed values are: {', '.join(self.allowed_values)}." | ||
|
||
|
||
class UnknownConfigAttributeError(Exception): | ||
def __init__(self, attribute: str) -> None: | ||
self.attribute = attribute | ||
|
||
def __str__(self) -> str: | ||
return f"Configuration has no attribute '{self.attribute}'" | ||
|
||
|
||
class ZabbixAuthConfigError(Exception): | ||
def __str__(self) -> str: | ||
return "You have to set token or username/password for Zabbix API" |
Oops, something went wrong.