Skip to content

Commit 81b801b

Browse files
committed
General cleanup
Ignore Pylance type errors which conflict with Mypy Refine types to be more correct
1 parent a56445a commit 81b801b

File tree

6 files changed

+30
-9
lines changed

6 files changed

+30
-9
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44
autoupdate_schedule: quarterly
55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.6.0
7+
rev: v5.0.0
88
hooks:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
@@ -17,7 +17,7 @@ repos:
1717
- id: fix-byte-order-marker
1818
- id: detect-private-key
1919
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.5.6
20+
rev: v0.9.10
2121
hooks:
2222
- id: ruff
2323
args: [--fix, --exit-non-zero-on-fix]

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
"files.insertFinalNewline": true,
55
"files.trimTrailingWhitespace": true,
66
"cSpell.words": [
7+
"addopts",
78
"automodule",
89
"autoupdate",
910
"autouse",
1011
"Benesch",
12+
"buildapi",
1113
"cattrs",
1214
"codecov",
15+
"docstrings",
16+
"doctest",
1317
"doctests",
1418
"dtype",
1519
"furo",
@@ -22,19 +26,28 @@
2226
"liskin",
2327
"maxdepth",
2428
"Mertens",
29+
"minversion",
2530
"modindex",
2631
"Mypy",
32+
"ncipollo",
2733
"Numpad",
2834
"PAGEDOWN",
2935
"PAGEUP",
3036
"pickleable",
37+
"pydocstyle",
38+
"pypa",
39+
"pypi",
40+
"pyright",
3141
"pytest",
3242
"quickstart",
3343
"RMASK",
3444
"rtype",
3545
"scancode",
3646
"setdefault",
47+
"setuptools",
48+
"subclassing",
3749
"tcod",
50+
"testpaths",
3851
"toctree",
3952
"Traceback",
4053
"typehints",

pyproject.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ warn_return_any = true
6666
no_implicit_reexport = true
6767
strict_equality = true
6868

69+
[tool.pyright]
70+
reportInconsistentOverload = false
71+
reportIncompatibleMethodOverride = false
72+
reportAssignmentType = false
73+
reportCallIssue = false
74+
reportInvalidTypeVarUse = false
75+
reportArgumentType = false
76+
6977
[tool.pytest.ini_options]
7078
minversion = "6.0"
7179
required_plugins = ["pytest-cov>=4.0.0", "pytest-benchmark>=4.0.0"]
@@ -81,8 +89,6 @@ line-length = 120
8189
[tool.ruff.lint] # https://docs.astral.sh/ruff/rules/
8290
select = ["ALL"]
8391
ignore = [
84-
"ANN101", # missing-type-self
85-
"ANN102", # missing-type-cls
8692
"COM", # flake8-commas, handled by formatter
8793
"E501", # line-too-long
8894
"S101", # assert

tcod/ecs/entity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Entity:
6666
>>> other_entity = registry["other"]
6767
""" # Changes here should be reflected in conftest.py
6868

69-
__slots__ = ("registry", "uid", "__weakref__")
69+
__slots__ = ("__weakref__", "registry", "uid")
7070

7171
registry: Final[Registry] # type:ignore[misc] # https://github.com/python/mypy/issues/5774
7272
"""The :any:`Registry` this entity belongs to."""
@@ -394,7 +394,7 @@ def _traverse_entities(start: Entity, traverse_parents: tuple[object, ...]) -> I
394394

395395

396396
@attrs.define(eq=False, frozen=True, weakref_slot=False)
397-
class EntityComponents(MutableMapping[Union[Type[Any], Tuple[object, Type[Any]]], Any]):
397+
class EntityComponents(MutableMapping[Union[Type[Any], Tuple[object, Type[Any]]], object]):
398398
"""A proxy attribute to access an entities components like a dictionary.
399399
400400
See :any:`Entity.components`.
@@ -552,7 +552,7 @@ def get(self, __key: ComponentKey[T], /, default: _T1 | None = None) -> T | _T1:
552552
except KeyError:
553553
return default # type: ignore[return-value] # https://github.com/python/mypy/issues/3737
554554

555-
def setdefault(self, __key: ComponentKey[T], __default: T) -> T: # type: ignore[override]
555+
def setdefault(self, __key: ComponentKey[T], __default: T, /) -> T:
556556
"""Assign a default value if a component is missing, then returns the current value."""
557557
try:
558558
return self[__key]
@@ -1040,7 +1040,7 @@ def __getitem__(self, key: ComponentKey[T]) -> EntityComponentRelationMapping[T]
10401040
"""Access relations for this component key as a `{target: component}` dict-like object."""
10411041
return EntityComponentRelationMapping(self.entity, key, self.traverse)
10421042

1043-
def __setitem__(self, __key: ComponentKey[T], __values: Mapping[Entity, object]) -> None:
1043+
def __setitem__(self, __key: ComponentKey[T], __values: Mapping[Entity, object], /) -> None:
10441044
"""Redefine the component relations for this entity.
10451045
10461046
..versionadded:: 4.2.0

tcod/ecs/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Common type-hints for tcod.ecs."""
1+
"""Common type-hints for tcod.ecs.""" # noqa: A005
22

33
from __future__ import annotations
44

tests/test_traversal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,5 @@ def test_inherited_clear() -> None:
215215
world["A"].relation_tags["baz"] = world["B"]
216216
child = world["A"].instantiate()
217217
child.clear() # Could hang if broken
218+
x = child.components
219+
x[int] = "asd"

0 commit comments

Comments
 (0)