diff --git a/pyproject.toml b/pyproject.toml index 98b7c8ad..2f390205 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -188,6 +188,28 @@ exclude = [ module = "django_components.*" disallow_untyped_defs = true +# TODO - Review these rules once we officially support Pylance / Pyright +# See https://github.com/django-components/django-components/issues/1397 +[tool.basedpyright] +reportMissingTypeArgument = "none" +reportUnknownParameterType = "none" +reportAny = "none" +reportExplicitAny = "none" +reportUnknownVariableType = "none" +reportUnknownArgumentType = "none" +reportUnknownMemberType = "none" +reportAttributeAccessIssue = "none" +reportPrivateUsage = "none" +reportConstantRedefinition = "none" +reportUnusedCallResult = "none" +reportImplicitStringConcatenation = "none" +reportUnannotatedClassAttribute = "none" +reportSelfClsParameterName = "none" +reportDeprecated = "none" +reportUnusedParameter = "none" +reportUninitializedInstanceVariable = "none" +reportRedeclaration = "none" +reportIncompatibleVariableOverride = "none" [tool.pytest.ini_options] testpaths = [ diff --git a/src/django_components/component.py b/src/django_components/component.py index 42bf6cb2..2102ef33 100644 --- a/src/django_components/component.py +++ b/src/django_components/component.py @@ -3609,8 +3609,8 @@ class Component(metaclass=ComponentMeta): html = None # Remove component from caches - del component_context_cache[render_id] # type: ignore[arg-type] - unregister_provide_reference(render_id) # type: ignore[arg-type] + del component_context_cache[render_id] + unregister_provide_reference(render_id) # Allow extensions to either: # - Override/modify the rendered HTML by returning new value diff --git a/src/django_components/util/loader.py b/src/django_components/util/loader.py index 88160b37..330b7019 100644 --- a/src/django_components/util/loader.py +++ b/src/django_components/util/loader.py @@ -151,7 +151,7 @@ def get_component_files(suffix: Optional[str] = None) -> List[ComponentFileEntry project_root = settings.BASE_DIR else: # Fallback for getting the root dir, see https://stackoverflow.com/a/16413955/9788634 - project_root = Path(__name__).parent.resolve() + project_root = Path.cwd() # NOTE: We handle dirs from `COMPONENTS.dirs` and from individual apps separately. modules: List[ComponentFileEntry] = [] diff --git a/src/django_components/util/testing.py b/src/django_components/util/testing.py index 9a839e0e..e26e7a3e 100644 --- a/src/django_components/util/testing.py +++ b/src/django_components/util/testing.py @@ -59,7 +59,7 @@ def is_testing() -> bool: class GenIdPatcher: def __init__(self) -> None: - self._gen_id_count = 10599485 + self._gen_id_count: int = 10599485 self._gen_id_patch: Any = None # Mock the `generate` function used inside `gen_id` so it returns deterministic IDs @@ -84,7 +84,7 @@ class GenIdPatcher: class CsrfTokenPatcher: def __init__(self) -> None: - self._csrf_token = "predictabletoken" # noqa: S105 + self._csrf_token: str = "predictabletoken" # noqa: S105 self._csrf_token_patch: Any = None def start(self) -> None: @@ -534,7 +534,7 @@ def _clear_djc_global_state( del ALL_COMPONENTS[reverse_index] # Remove registries that were created during the test - initial_registries_set: Set[RegistryRef] = {reg_ref for reg_ref, init_keys in initial_registries_copies} + initial_registries_set: Set[RegistryRef] = {reg_ref for reg_ref, _init_keys in initial_registries_copies} for index in range(len(ALL_REGISTRIES)): registry_ref = ALL_REGISTRIES[len(ALL_REGISTRIES) - index - 1] is_ref_deleted = registry_ref() is None