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

Update pylint to 2.13.0 #68656

Merged
merged 7 commits into from
Mar 25, 2022
Merged

Update pylint to 2.13.0 #68656

merged 7 commits into from
Mar 25, 2022

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Mar 25, 2022

Proposed change

Update pylint to 2.13.0.
This is a bigger feature update, see below for some notable changes. I'll open a followup to remove pylint: disable messages which now have become obsolete. Those are not included here to keep the diff a bit smaller.

Release post: https://pylint.pycqa.org/en/latest/whatsnew/2.13.html
Compare view: pylint-dev/pylint@v2.12.2...v2.13.0

Notable changes

  • Improved error ranges for class and function issues. Especially useful with the VS Code Python extension.
  • Several new checkers for unicode security issues, including Trojan Sources.
  • Improved invalid-name checker for TypeVars. See Make TypeVars private (1) #68205
    • Some good name: T, _U, AnyStr, _CallableT, _EntityT, T_co, T_contra
    • Some bad names: T_CALLABLE, SomeType (or anything ending in Type)
    • Private names are recommended, although not a requirement by pylint. Make TypeVars private (1) #68205 (comment)
  • Several changes / improvements to the used-before-assignment logic, especially with try / except blocks.
  • Detect if a staticmethod is overwritten with an instance method (or the other way round). Usually, staticmethod can be removed in these cases as the methods are called from the instance anyway.
  • New redefined-slots-in-subclass checker. __slots__ in subclasses should not contain items from the parent class __slots__. Python docs.
However, child subclasses will get a __dict__ and __weakref__ unless they also define __slots__
(which should only contain names of any additional slots).
  • Relaxed arguments-differ check to allow redefinitions with extra parameters if those have default values.
class LightEntity:
    async def async_turn_on(self, **kwargs: Any) -> None:
        ...

class SomeLight(LightEntity):
    async def async_turn_on(
        self,
        *,
        brightness: int | None = None,
        effect: str | None = None,
        **kwargs: Any,
    ) -> None:
        ...

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@cdce8p cdce8p marked this pull request as ready for review March 25, 2022 02:59
@@ -86,28 +88,23 @@ def name(self) -> str:
"""Return the Alexa API name of this interface."""
raise NotImplementedError

@staticmethod
def properties_supported() -> list[dict]:
Copy link
Member

Choose a reason for hiding this comment

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

Why change this?

Copy link
Member Author

Choose a reason for hiding this comment

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

These static methods are overwritten with normal instance methods. Which means technically the signatures aren't compatible. You can't, for example, just exchange a call to AlexaCapability.properties_supported with one to a subclass AlexaEndpointHealth.properties_supported.

def properties_supported(self):
"""Return what properties this entity supports."""
return [{"name": "powerState"}]

Furthermore, they are accessed via self.xxx anyway. So removing staticmethod here seems fine.

properties_supported = self.properties_supported()
if properties_supported:
result["properties"] = {
"supported": self.properties_supported(),
"proactivelyReported": self.properties_proactively_reported(),
"retrievable": self.properties_retrievable(),
}

@balloob balloob merged commit 53245c6 into home-assistant:dev Mar 25, 2022
@cdce8p cdce8p deleted the pylint-2.13.0 branch March 25, 2022 22:25
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants