Compare commits

...

9 commits

Author SHA1 Message Date
ef25e8a026 Mod: make mypy happy
Moved the enabled setter next to the property, and made type hints
more accurate
2025-05-14 17:37:13 +02:00
3a8406cb19 Mod: return enabled as a bool instead of str 2025-05-14 17:33:59 +02:00
8349e4f340 Add src to mypy path 2025-05-14 17:23:06 +02:00
fb81e2bd1f Make ruff happier 2025-05-14 16:25:30 +02:00
9d4b229b44 Enable more ruff rules 2025-05-14 16:12:45 +02:00
64fd7d47e6 Set minimum supported python version 2025-05-14 16:03:34 +02:00
d53fe7160f Ignore missing type info from pyside 2025-05-14 14:50:46 +02:00
bc6c17b940 Flake: add mypy and pylsp-mypy 2025-05-13 21:00:06 +02:00
b5c6b33c68 Flake: make shell with no compiler 2025-05-11 14:57:57 +02:00
3 changed files with 46 additions and 19 deletions

View file

@ -9,13 +9,15 @@
lib = nixpkgs.lib;
in
{
devShells.x86_64-linux.default = pkgs.mkShell {
devShells.x86_64-linux.default = pkgs.mkShellNoCC {
name = "leek-devshell";
packages = with pkgs; [
ruff
(
python3.withPackages (ps: with ps;[
python-lsp-server
pylsp-mypy
mypy
pyside6
tomlkit
]

View file

@ -18,6 +18,7 @@ dependencies = [
"pyside6",
"tomlkit",
]
requires-python = ">=3.6"
[project.readme]
file = "README.md"
@ -31,6 +32,30 @@ packages = ["leek"]
package-dir = {leek = "src"}
include-package-data = true
[tool.ruff.lint]
select = [
# Defaults
"E4",
"E7",
"E9",
"F",
"W", # Pycodestyle warning
"N" # Pep-8 naming
]
[tool.mypy]
mypy_path = "$MYPY_CONFIG_FILE_DIR/src"
# Pyside 6 doesn't have type info so it's better to just ignore it
[[tool.mypy.overrides]]
module = [
"PySide6.QtGui",
"PySide6.QtCore",
"PySide6.QtQml"
]
ignore_missing_imports = true
[tool.setuptools.data-files]
"share/applications" = ["xyz.toast003.leek.desktop"]

View file

@ -11,35 +11,24 @@ class Mod:
def name(self) -> str | None:
if "name" not in self.__config:
return None
return self.__config["name"]
return self.__config["name"].as_string()
@property
def description(self) -> str | None:
if "description" not in self.__config.keys():
return None
else:
return self.__config["description"]
return self.__config["description"].as_string()
@property
def author(self) -> str | None:
if "author" not in self.__config:
return None
return self.__config["author"]
return self.__config["author"].as_string()
@property
def enabled(self) -> str:
return self.__enabled
def __init__(self, path: str) -> None:
self.__path = path
with open(path + "config.toml") as configFile:
self.__config = tomlkit.load(configFile)
if "enabled" not in self.__config:
raise InvalidModError("config.toml does not contain the enabled key")
else:
self.__enabled = self.__config["enabled"]
def enabled(self) -> bool:
return True if self.__enabled == "true" else False
@enabled.setter
def enabled(self, value: bool) -> None:
@ -47,9 +36,20 @@ class Mod:
# Nothing to do
return
with open(self.__path + "config.toml", "w") as configFile:
with open(self.__path + "config.toml", "w") as config_file:
self.__config["enabled"] = value
tomlkit.dump(self.__config, configFile)
tomlkit.dump(self.__config, config_file)
def __init__(self, path: str) -> None:
self.__path = path
with open(path + "config.toml") as config_file:
self.__config = tomlkit.load(config_file)
if "enabled" not in self.__config:
raise InvalidModError("config.toml does not contain the enabled key")
else:
self.__enabled = self.__config["enabled"]
def __str__(self) -> str:
return f"Mod({self.__path})"