From ecca4c65c8eda8b1f925136b2d3f3c7e500e2542 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Wed, 27 Sep 2023 14:16:52 +0100 Subject: [PATCH] add pyproject.toml --- .vscode/settings.json | 5 +-- addon/globalPlugins/voicemeeter/cdll.py | 2 +- addon/globalPlugins/voicemeeter/context.py | 14 ++++--- addon/globalPlugins/voicemeeter/error.py | 2 +- pyproject.toml | 46 ++++++++++++++++++++++ 5 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 pyproject.toml diff --git a/.vscode/settings.json b/.vscode/settings.json index 4aa92b0..25dc677 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,5 @@ { "python.analysis.diagnosticSeverityOverrides": { "reportMissingImports": "none" - }, - "black-formatter.args": [ - "--line-length=120" - ] + } } \ No newline at end of file diff --git a/addon/globalPlugins/voicemeeter/cdll.py b/addon/globalPlugins/voicemeeter/cdll.py index 3f31a5e..a439860 100644 --- a/addon/globalPlugins/voicemeeter/cdll.py +++ b/addon/globalPlugins/voicemeeter/cdll.py @@ -35,7 +35,7 @@ def get_vmpath(): try: vm_parent = Path(get_vmpath()).parent except FileNotFoundError as e: - raise VMError(f"Unable to fetch DLL path from the registry") from e + raise VMError("Unable to fetch DLL path from the registry") from e DLL_NAME = f'VoicemeeterRemote{"64" if BITS == 64 else ""}.dll' diff --git a/addon/globalPlugins/voicemeeter/context.py b/addon/globalPlugins/voicemeeter/context.py index 5474122..e6b50ff 100644 --- a/addon/globalPlugins/voicemeeter/context.py +++ b/addon/globalPlugins/voicemeeter/context.py @@ -8,12 +8,8 @@ class Strategy(ABC): self._slider_mode = "gain" @abstractmethod - def __str__(self): - pass - - @property def identifier(self): - return f"{self}[{self._index}]" + pass @property def index(self): @@ -54,11 +50,19 @@ class StripStrategy(Strategy): def __str__(self): return "Strip" + @property + def identifier(self): + return f"{self}[{self._index}]" + class BusStrategy(Strategy): def __str__(self): return "Bus" + @property + def identifier(self): + return f"{self}[{self._index}]" + class Context: def __init__(self, strategy: Strategy) -> None: diff --git a/addon/globalPlugins/voicemeeter/error.py b/addon/globalPlugins/voicemeeter/error.py index 43f7043..bd6c984 100644 --- a/addon/globalPlugins/voicemeeter/error.py +++ b/addon/globalPlugins/voicemeeter/error.py @@ -1,5 +1,5 @@ class VMError(Exception): - """Base voicemeeterlib exception class.""" + """Base voicemeeterlib exception class""" class VMCAPIError(VMError): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..eecd131 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,46 @@ +[tool.black] +line-length = 119 + +[tool.ruff] +# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. +select = ["E", "F"] +# Avoid enforcing line-length violations (`E501`). Let Black deal with this. +ignore = ["E501"] +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"] +unfixable = [] +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", +] +# Same as Black. +line-length = 119 +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" +# Assume Python 3.7 +target-version = "py37" +[tool.ruff.mccabe] +# Unlike Flake8, default to a complexity level of 10. +max-complexity = 10 +[tool.ruff.per-file-ignores] +"__init__.py" = ["E402", "F401"] # Ignore unused import and variable not accessed violations \ No newline at end of file