Mod: make mypy happy
Moved the enabled setter next to the property, and made type hints more accurate
This commit is contained in:
parent
3a8406cb19
commit
ef25e8a026
1 changed files with 13 additions and 13 deletions
26
src/mod.py
26
src/mod.py
|
|
@ -11,25 +11,35 @@ 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) -> bool:
|
||||
return True if self.__enabled == "true" else False
|
||||
|
||||
@enabled.setter
|
||||
def enabled(self, value: bool) -> None:
|
||||
if value == self.__enabled:
|
||||
# Nothing to do
|
||||
return
|
||||
|
||||
with open(self.__path + "config.toml", "w") as config_file:
|
||||
self.__config["enabled"] = value
|
||||
tomlkit.dump(self.__config, config_file)
|
||||
|
||||
def __init__(self, path: str) -> None:
|
||||
self.__path = path
|
||||
|
||||
|
|
@ -41,16 +51,6 @@ class Mod:
|
|||
else:
|
||||
self.__enabled = self.__config["enabled"]
|
||||
|
||||
@enabled.setter
|
||||
def enabled(self, value: bool) -> None:
|
||||
if value == self.__enabled:
|
||||
# Nothing to do
|
||||
return
|
||||
|
||||
with open(self.__path + "config.toml", "w") as config_file:
|
||||
self.__config["enabled"] = value
|
||||
tomlkit.dump(self.__config, config_file)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"Mod({self.__path})"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue