mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
fix some pycharm warnings
This commit is contained in:
parent
e42ca95789
commit
31f47b8069
@ -55,7 +55,7 @@ class Shell(Handler):
|
||||
# licensed by https://creativecommons.org/licenses/by-sa/3.0
|
||||
path = Path(sys.prefix) / "share" / "ahriman" / "templates" / "shell"
|
||||
StringPrinter(path.read_text(encoding="utf8")).print(verbose=False)
|
||||
# we only want to pass application isntance inside
|
||||
# we only want to pass application instance inside
|
||||
if args.code is None:
|
||||
code.interact(local={"application": application})
|
||||
else:
|
||||
|
@ -27,6 +27,7 @@ from ahriman.core.sign.gpg import GPG
|
||||
from ahriman.core.status.client import Client
|
||||
from ahriman.core.triggers import TriggerLoader
|
||||
from ahriman.core.util import check_user
|
||||
from ahriman.models.repository_paths import RepositoryPaths
|
||||
|
||||
|
||||
class RepositoryProperties(LazyLogging):
|
||||
@ -68,7 +69,7 @@ class RepositoryProperties(LazyLogging):
|
||||
self.name = configuration.get("repository", "name")
|
||||
self.vcs_allowed_age = configuration.getint("build", "vcs_allowed_age", fallback=0)
|
||||
|
||||
self.paths = configuration.repository_paths
|
||||
self.paths: RepositoryPaths = configuration.repository_paths # additional workaround for pycharm typing
|
||||
try:
|
||||
check_user(self.paths, unsafe=unsafe)
|
||||
self.paths.tree_create()
|
||||
|
@ -20,10 +20,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import importlib
|
||||
import os
|
||||
|
||||
from collections.abc import Generator
|
||||
from importlib import import_module, machinery
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
|
||||
@ -128,7 +128,7 @@ class TriggerLoader(LazyLogging):
|
||||
self.logger.info("load module %s from path %s", implementation, module_path)
|
||||
# basically this method is called only if ``module_path`` exists and is file.
|
||||
# Thus, this method should never throw ``FileNotFoundError`` exception
|
||||
loader = importlib.machinery.SourceFileLoader(implementation, module_path)
|
||||
loader = machinery.SourceFileLoader(implementation, module_path)
|
||||
module = ModuleType(loader.name)
|
||||
loader.exec_module(module)
|
||||
|
||||
@ -149,7 +149,7 @@ class TriggerLoader(LazyLogging):
|
||||
"""
|
||||
self.logger.info("load module from package %s", package)
|
||||
try:
|
||||
return importlib.import_module(package)
|
||||
return import_module(package)
|
||||
except ModuleNotFoundError:
|
||||
raise ExtensionError(f"Module {package} not found")
|
||||
|
||||
|
@ -33,14 +33,14 @@ class InternalStatusSchema(Schema):
|
||||
"description": "Repository architecture",
|
||||
"example": "x86_64",
|
||||
})
|
||||
packages = fields.Nested(CountersSchema, required=True, metadata={
|
||||
packages = fields.Nested(CountersSchema(), required=True, metadata={
|
||||
"description": "Repository package counters",
|
||||
})
|
||||
repository = fields.String(required=True, metadata={
|
||||
"description": "Repository name",
|
||||
"example": "repo-clone",
|
||||
})
|
||||
status = fields.Nested(StatusSchema, required=True, metadata={
|
||||
status = fields.Nested(StatusSchema(), required=True, metadata={
|
||||
"description": "Repository status as stored by web service",
|
||||
})
|
||||
version = fields.String(required=True, metadata={
|
||||
|
@ -31,7 +31,7 @@ class LogsSchema(Schema):
|
||||
"description": "Package base name",
|
||||
"example": "ahriman",
|
||||
})
|
||||
status = fields.Nested(StatusSchema, required=True, metadata={
|
||||
status = fields.Nested(StatusSchema(), required=True, metadata={
|
||||
"description": "Last package status",
|
||||
})
|
||||
logs = fields.String(required=True, metadata={
|
||||
|
@ -37,10 +37,10 @@ class PackageSchema(Schema):
|
||||
"description": "Package version",
|
||||
"example": version.__version__,
|
||||
})
|
||||
remote = fields.Nested(RemoteSchema, required=True, metadata={
|
||||
remote = fields.Nested(RemoteSchema(), required=True, metadata={
|
||||
"description": "Package remote properties",
|
||||
})
|
||||
packages = fields.Dict(
|
||||
keys=fields.String(), values=fields.Nested(PackagePropertiesSchema), required=True, metadata={
|
||||
keys=fields.String(), values=fields.Nested(PackagePropertiesSchema()), required=True, metadata={
|
||||
"description": "Packages which belong to this base",
|
||||
})
|
||||
|
@ -29,7 +29,7 @@ class PackageStatusSimplifiedSchema(Schema):
|
||||
special request package status schema
|
||||
"""
|
||||
|
||||
package = fields.Nested(PackageSchema, metadata={
|
||||
package = fields.Nested(PackageSchema(), metadata={
|
||||
"description": "Package description",
|
||||
})
|
||||
status = fields.Enum(BuildStatusEnum, by_value=True, required=True, metadata={
|
||||
@ -42,9 +42,9 @@ class PackageStatusSchema(Schema):
|
||||
response package status schema
|
||||
"""
|
||||
|
||||
package = fields.Nested(PackageSchema, required=True, metadata={
|
||||
package = fields.Nested(PackageSchema(), required=True, metadata={
|
||||
"description": "Package description",
|
||||
})
|
||||
status = fields.Nested(StatusSchema, required=True, metadata={
|
||||
status = fields.Nested(StatusSchema(), required=True, metadata={
|
||||
"description": "Last package status",
|
||||
})
|
||||
|
@ -52,7 +52,7 @@ def test_load_trigger_class_package_invalid_import(trigger_loader: TriggerLoader
|
||||
"""
|
||||
must raise InvalidExtension on invalid import
|
||||
"""
|
||||
mocker.patch("ahriman.core.triggers.trigger_loader.importlib.import_module", side_effect=ModuleNotFoundError())
|
||||
mocker.patch("importlib.import_module", side_effect=ModuleNotFoundError())
|
||||
with pytest.raises(ExtensionError):
|
||||
trigger_loader.load_trigger_class("random.module")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user