mirror of
https://github.com/django-components/django-components.git
synced 2025-09-25 15:09:15 +00:00
refactor: allow to use pylance/pyright with the codebase (#1403)
This commit is contained in:
parent
340d58f391
commit
8ee616fad7
4 changed files with 28 additions and 6 deletions
|
@ -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 = [
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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] = []
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue