Skip to content

Commit 2f1e864

Browse files
authored
Merge pull request #293 from python-ellar/mypy_fix3oct
Fix mypy errors: resolve type issues and remove unused type ignores
2 parents 7dc6f4f + b34798c commit 2f1e864

File tree

48 files changed

+216
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+216
-114
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ help:
55
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
66

77
clean: ## Removing cached python compiled files
8-
find . -name \*pyc | xargs rm -fv
9-
find . -name \*pyo | xargs rm -fv
10-
find . -name \*~ | xargs rm -fv
11-
find . -name __pycache__ | xargs rm -rfv
12-
find . -name .ruff_cache | xargs rm -rfv
8+
find . -name "*.pyc" -type f -delete
9+
find . -name "*.pyo" -type f -delete
10+
find . -name "*~" -type f -delete
11+
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
12+
find . -name ".ruff_cache" -type d -exec rm -rf {} + 2>/dev/null || true
1313

1414
install: ## Install dependencies
1515
pip install -r requirements.txt

ellar/app/lifespan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def lifespan(self, app: "App") -> t.AsyncIterator[t.Any]:
6060
logger.debug("Executing Modules Startup Handlers")
6161
await self.run_all_startup_actions(app)
6262

63-
async with self._lifespan_context(app) as ctx: # type:ignore[attr-defined]
63+
async with self._lifespan_context(app) as ctx:
6464
logger.info("Application is ready.")
6565
yield ctx
6666
finally:

ellar/app/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def __init__(
5353
):
5454
_routes = routes or []
5555
assert isinstance(config, Config), "config must instance of Config"
56-
assert isinstance(
57-
injector, EllarInjector
58-
), "injector must instance of EllarInjector"
56+
assert isinstance(injector, EllarInjector), (
57+
"injector must instance of EllarInjector"
58+
)
5959

6060
self._config = config
6161
self._injector: EllarInjector = injector
@@ -70,7 +70,7 @@ def __init__(
7070
redirect_slashes=self.config.REDIRECT_SLASHES,
7171
default=self.config.DEFAULT_NOT_FOUND_HANDLER,
7272
lifespan=EllarApplicationLifespan(
73-
self.config.DEFAULT_LIFESPAN_HANDLER # type: ignore[arg-type]
73+
self.config.DEFAULT_LIFESPAN_HANDLER
7474
).lifespan,
7575
)
7676

ellar/auth/handlers/schemes/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _get_credentials(self, connection: "HTTPConnection") -> HTTPBasicCredentials
9494

9595
if not separator:
9696
self._not_unauthorized_exception("Invalid authentication credentials")
97-
return HTTPBasicCredentials(username=username, password=password) # type: ignore[arg-type]
97+
return HTTPBasicCredentials(username=username, password=password)
9898

9999

100100
class HttpDigestAuth(HttpBearerAuth, ABC):

ellar/auth/policy/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MyPolicyHandler(PolicyWithRequirement):
1919
"""
2020

2121
def __init__(self, *args: t.Any) -> None:
22-
kwargs_args = {f"arg_{idx+1}": value for idx, value in enumerate(args)}
22+
kwargs_args = {f"arg_{idx + 1}": value for idx, value in enumerate(args)}
2323
super().__init__(kwargs_args)
2424

2525

ellar/cache/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def setup(
3434
args = {"default": default}
3535
args.update(kwargs)
3636

37-
schema = CacheModuleSchemaSetup(**{"CACHES": args}) # type: ignore[arg-type]
37+
schema = CacheModuleSchemaSetup(**{"CACHES": args})
3838
return cls._create_dynamic_module(schema)
3939

4040
@classmethod

ellar/cache/service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def __init__(
8484
self, backends: t.Optional[t.Dict[str, BaseCacheBackend]] = None
8585
) -> None:
8686
if backends:
87-
assert backends.get(
88-
"default"
89-
), "CACHES configuration must have a 'default' key."
87+
assert backends.get("default"), (
88+
"CACHES configuration must have a 'default' key."
89+
)
9090
self._backends = backends or {
9191
"default": LocalMemCacheBackend(key_prefix="ellar", version=1, ttl=300)
9292
}

ellar/common/decorators/controller.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def Controller(
4242
_prefix = NOT_SET
4343

4444
if _prefix is not NOT_SET:
45-
assert _prefix == "" or str(_prefix).startswith(
46-
"/"
47-
), "Controller Prefix must start with '/'"
45+
assert _prefix == "" or str(_prefix).startswith("/"), (
46+
"Controller Prefix must start with '/'"
47+
)
4848
# TODO: replace with a ControllerTypeDict and OpenAPITypeDict
4949
kwargs = AttributeDict(
5050
path=_prefix,

ellar/common/decorators/html.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def render(template_name: t.Optional[str] = NOT_SET) -> t.Callable:
4141
:return:
4242
"""
4343
if template_name is not NOT_SET:
44-
assert isinstance(
45-
template_name, str
46-
), "Render Operation must invoked eg. @render()"
44+
assert isinstance(template_name, str), (
45+
"Render Operation must invoked eg. @render()"
46+
)
4747
template_name = None if template_name is NOT_SET else template_name
4848

4949
def _decorator(func: t.Union[t.Callable, t.Any]) -> t.Union[t.Callable, t.Any]:

ellar/common/decorators/modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def Module(
9191
9292
:return: t.TYPE[ModuleBase]
9393
"""
94-
base_directory = get_main_directory_by_stack(base_directory, stack_level=2) # type:ignore[arg-type]
94+
base_directory = get_main_directory_by_stack(base_directory, stack_level=2)
9595
kwargs = AttributeDict(
9696
name=name,
9797
controllers=list(controllers),

0 commit comments

Comments
 (0)