Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:
python-typecheck:
name: Python Type Check
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v6
Expand All @@ -77,8 +76,9 @@ jobs:
with:
python-version: "3.12"

- name: Install Pyright
run: pip install pyright
- name: Install dependencies
working-directory: src/python
run: pip install -r requirements.txt pyright

- name: Pyright
working-directory: src/python
Expand Down Expand Up @@ -334,10 +334,11 @@ jobs:
&& (startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/develop' && github.event_name == 'push') || github.event_name == 'workflow_dispatch')
&& needs.unit-test.result == 'success'
&& needs.python-lint.result == 'success'
&& needs.python-typecheck.result == 'success'
&& needs.python-test.result == 'success'
&& needs.build-amd64.result == 'success'
&& needs.build-arm64.result == 'success'
needs: [unit-test, python-lint, python-test, build-amd64, build-arm64]
needs: [unit-test, python-lint, python-typecheck, python-test, build-amd64, build-arm64]
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
22 changes: 11 additions & 11 deletions src/python/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class ConfigError(AppError):

class Converters:
@staticmethod
def null(_: T, __: str, value: str) -> str:
def null(_: T, __: str, value: str) -> str: # type: ignore[reportInvalidTypeVarUse]
return value

@staticmethod
def int(cls: T, name: str, value: str) -> int:
def int(cls: T, name: str, value: str) -> int: # type: ignore[reportInvalidTypeVarUse, reportSelfClsParameterName]
if not value:
raise ConfigError("Bad config: {}.{} is empty".format(cls.__name__, name))
try:
Expand All @@ -54,7 +54,7 @@ def int(cls: T, name: str, value: str) -> int:
return val

@staticmethod
def bool(cls: T, name: str, value: str) -> bool:
def bool(cls: T, name: str, value: str) -> bool: # type: ignore[reportInvalidTypeVarUse, reportSelfClsParameterName]
if not value:
raise ConfigError("Bad config: {}.{} is empty".format(cls.__name__, name))
try:
Expand All @@ -66,33 +66,33 @@ def bool(cls: T, name: str, value: str) -> bool:

class Checkers:
@staticmethod
def null(_: T, __: str, value: Any) -> Any:
def null(_: T, __: str, value: Any) -> Any: # type: ignore[reportInvalidTypeVarUse]
return value

@staticmethod
def string_nonempty(cls: T, name: str, value: str) -> str:
def string_nonempty(cls: T, name: str, value: str) -> str: # type: ignore[reportInvalidTypeVarUse, reportSelfClsParameterName]
if not value or not value.strip():
raise ConfigError("Bad config: {}.{} is empty".format(cls.__name__, name))
return value

@staticmethod
def string_allow_empty(cls: T, name: str, value: str) -> str:
def string_allow_empty(cls: T, name: str, value: str) -> str: # type: ignore[reportInvalidTypeVarUse, reportSelfClsParameterName]
return value

@staticmethod
def int_non_negative(cls: T, name: str, value: int) -> int:
def int_non_negative(cls: T, name: str, value: int) -> int: # type: ignore[reportInvalidTypeVarUse, reportSelfClsParameterName]
if value < 0:
raise ConfigError("Bad config: {}.{} ({}) must be zero or greater".format(cls.__name__, name, value))
return value

@staticmethod
def int_positive(cls: T, name: str, value: int) -> int:
def int_positive(cls: T, name: str, value: int) -> int: # type: ignore[reportInvalidTypeVarUse, reportSelfClsParameterName]
if value < 1:
raise ConfigError("Bad config: {}.{} ({}) must be greater than 0".format(cls.__name__, name, value))
return value

@staticmethod
def algorithm_allowed(cls: T, name: str, value: str) -> str:
def algorithm_allowed(cls: T, name: str, value: str) -> str: # type: ignore[reportInvalidTypeVarUse, reportSelfClsParameterName]
allowed = {"md5", "sha1", "sha256"}
normalized = value.strip().lower() if value else ""
if normalized not in allowed:
Expand Down Expand Up @@ -404,7 +404,7 @@ def _check_empty_outer_dict(dct: OuterConfigType):

@classmethod
@overrides(Persist)
def from_str(cls: "Config", content: str) -> "Config":
def from_str(cls: type["Config"], content: str) -> "Config":
config_parser = configparser.ConfigParser()
try:
config_parser.read_string(content)
Expand All @@ -415,7 +415,7 @@ def from_str(cls: "Config", content: str) -> "Config":
config_dict[section] = {}
for option in config_parser.options(section):
config_dict[section][option] = config_parser.get(section, option)
return Config.from_dict(config_dict)
return cls.from_dict(config_dict)

@overrides(Persist)
def to_str(self) -> str:
Expand Down
Loading
Loading