Skip to content

Fix a reportUnnecessaryIsInstance Pyright warning - #4263

Merged
svartkanin merged 1 commit into
archlinux:masterfrom
correctmost:cm/fix-pyright-warning
Feb 27, 2026
Merged

Fix a reportUnnecessaryIsInstance Pyright warning#4263
svartkanin merged 1 commit into
archlinux:masterfrom
correctmost:cm/fix-pyright-warning

Conversation

@correctmost

Copy link
Copy Markdown
Contributor

PR Description:

This PR fixes the following warning:

archinstall/archinstall/lib/models/device.py:321:10 - error: Unnecessary isinstance call; "SectorSize" is always an instance of "SectorSize" (reportUnnecessaryIsInstance)

@correctmost
correctmost requested a review from Torxed as a code owner February 27, 2026 06:25
@svartkanin
svartkanin merged commit d413c01 into archlinux:master Feb 27, 2026
9 checks passed
@correctmost
correctmost deleted the cm/fix-pyright-warning branch February 27, 2026 06:42
@codefiles

codefiles commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

I've thought about removing the following __post_init__ in the past.

def __post_init__(self) -> None:
if self.luks_dev_path is None:
raise ValueError('Partition must have a path set')

Here is the luks_dev_path type annotation:

@dataclass
class Luks2:
luks_dev_path: Path
mapper_name: str | None = None
password: Password | None = None
key_file: Path | None = None
auto_unmount: bool = False

It is checking for None instead of using isinstance so it does not trigger the reportUnnecessaryIsInstance Pyright warning. This is pretty much the same design defect though, an unnecessary type check in a post-init, right?

@correctmost

Copy link
Copy Markdown
Contributor Author

This is pretty much the same design defect though, an unnecessary type check in a post-init, right?

Yeah :). I would like to enable mypy --strict-equality-for-none to catch these extraneous checks, but there are a bunch of places that need to be cleaned up first:

$ mypy --strict-equality-for-none
[...snip...]
archinstall/lib/luks.py:44: error: Non-overlapping identity check (left operand type: "Path", right operand type: "None")  [comparison-overlap]
[...snip...]

@codefiles

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants