Skip to content

More ruff and warning cleanup - #356

Merged
sveinse merged 9 commits into
custom-components:masterfrom
steinmn:more-ruff-and-warning-cleanup
Jun 29, 2026
Merged

More ruff and warning cleanup#356
sveinse merged 9 commits into
custom-components:masterfrom
steinmn:more-ruff-and-warning-cleanup

Conversation

@steinmn

@steinmn steinmn commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

Bringing the number of ruff errors down below 50.

Part of #258

Gave the warning `Argument of type "Iterable[EntityDescription]" cannot be assigned to parameter "descriptions" of type "Iterable[ZaptecEntityDescription]" in function "create_entities_from_descriptions"`
Brings the remaining errors down to below 50

@sveinse sveinse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!. I have a few comments it would be good to discuss

Comment thread custom_components/zaptec/zaptec/api.py
Comment thread custom_components/zaptec/zaptec/api.py
Comment thread custom_components/zaptec/zaptec/api.py Outdated

@dataclass(frozen=True, kw_only=True)
class ZapBinarySensorEntityDescription(BinarySensorEntityDescription):
class ZapBinarySensorEntityDescription(ZaptecEntityDescription, BinarySensorEntityDescription):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, doesn't this result in a diamond inheritance? Does this have any practical effects in this usage? I've been taught to avoid them like the plague.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be honest, I'd never heard of diamond inheritance before. Having said that, is this really any different from
class ZaptecBinarySensor(ZaptecBaseEntity, BinarySensorEntity):
a couple of lines above this? Both inherit from the Entity class (if you dig down a bit). Also, these particular classes only add (non-overlapping) variables, so there's no ambiguity.

This was done to avoid the warning Argument of type "Iterable[EntityDescription]" cannot be assigned to parameter "descriptions" of type "Iterable[ZaptecEntityDescription]" in function "create_entities_from_descriptions". Unsure about the practical effects.

Comment thread custom_components/zaptec/diagnostics.py
Comment thread custom_components/zaptec/services.py
Comment thread custom_components/zaptec/diagnostics.py
Comment thread custom_components/zaptec/zaptec/api.py
Comment thread custom_components/zaptec/zaptec/api.py
Comment thread custom_components/zaptec/zaptec/api.py Outdated
@sveinse

sveinse commented Nov 9, 2025

Copy link
Copy Markdown
Collaborator

@steinmn Do we want this in place before the pending 0.8.6 release?

@steinmn

steinmn commented Nov 9, 2025

Copy link
Copy Markdown
Contributor Author

@steinmn Do we want this in place before the pending 0.8.6 release?

I don't think so. It's a lot of small changes which (hopefully) only impacts code quality stuff, so probably better to just get a stable version out and then have some more time to discuss all the points above.

@steinmn
steinmn requested a review from sveinse November 27, 2025 13:44
@sveinse sveinse mentioned this pull request Apr 23, 2026
@sveinse

sveinse commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

This is a long standing PR and I'm inclined to just get it in there and see what happens. I do not have any detailed objections to it. Any objections to merging this into master at this point? We can probably observe the fallout as we go, right?

@sveinse sveinse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - this takes us closer to a better linted codebase, while not 100% perfect, its good enough to move us forward.

Comment thread custom_components/zaptec/zaptec/api.py
Comment thread custom_components/zaptec/zaptec/api.py
@steinmn

steinmn commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

This is a long standing PR and I'm inclined to just get it in there and see what happens. I do not have any detailed objections to it. Any objections to merging this into master at this point? We can probably observe the fallout as we go, right?

Agreed 👍

@sveinse
sveinse merged commit 329fcab into custom-components:master Jun 29, 2026
6 checks passed
@steinmn
steinmn deleted the more-ruff-and-warning-cleanup branch July 1, 2026 20:06
@sveinse sveinse added this to the v0.8.8 milestone Jul 8, 2026
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.

2 participants