Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak type annotations for pylint #1028

Merged
merged 1 commit into from
Sep 25, 2023
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
5 changes: 3 additions & 2 deletions src/modlunky2/levels/level_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from collections import OrderedDict
from typing import ClassVar, Generic, Optional, TextIO, TypeVar
from typing import ClassVar, Generic, Optional, TextIO, TypeVar, cast

from modlunky2.levels.utils import (
DirectivePrefixes,
Expand Down Expand Up @@ -115,7 +115,8 @@ def clean_value(self):
return

if self.name == "size":
value = tuple(self.value.split())
# The cast is for pylint, which doesn't recognize the narrowing of isinstance
value = tuple(cast(self.value, str).split())
if len(value) != 2:
raise ValueError("Directive `size` expects 2 values.")
elif self.name == "liquid_gravity":
Expand Down
4 changes: 2 additions & 2 deletions src/modlunky2/mem/memrauder/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class _StructField:
@dataclass(frozen=True)
class DataclassStruct(MemType[T]):
path: FieldPath
dataclass: T
dataclass: Type[T]

struct_fields: Dict[str, _StructField] = dataclasses.field(init=False)

Expand Down Expand Up @@ -358,7 +358,7 @@ def __str__(self):
@dataclass(frozen=True)
class ScalarCType(BiMemType[T]):
path: FieldPath
py_type: T
py_type: Type[T]
c_type: type

# Dict doesn't work correctly, presumably c_foo isn't hashable
Expand Down