Add pylint directory to black pre-commit (#78011)
Add pylint to black CI
This commit is contained in:
parent
37631d2017
commit
23168434d5
2 changed files with 11 additions and 4 deletions
|
@ -11,7 +11,7 @@ repos:
|
|||
args:
|
||||
- --safe
|
||||
- --quiet
|
||||
files: ^((homeassistant|script|tests)/.+)?[^/]+\.py$
|
||||
files: ^((homeassistant|pylint|script|tests)/.+)?[^/]+\.py$
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.1.0
|
||||
hooks:
|
||||
|
|
|
@ -303,9 +303,13 @@ class HassImportsFormatChecker(BaseChecker): # type: ignore[misc]
|
|||
if module.startswith(f"{self.current_package}."):
|
||||
self.add_message("hass-relative-import", node=node)
|
||||
|
||||
def _visit_importfrom_relative(self, current_package: str, node: nodes.ImportFrom) -> None:
|
||||
def _visit_importfrom_relative(
|
||||
self, current_package: str, node: nodes.ImportFrom
|
||||
) -> None:
|
||||
"""Called when a ImportFrom node is visited."""
|
||||
if node.level <= 1 or not current_package.startswith("homeassistant.components"):
|
||||
if node.level <= 1 or not current_package.startswith(
|
||||
"homeassistant.components"
|
||||
):
|
||||
return
|
||||
split_package = current_package.split(".")
|
||||
if not node.modname and len(split_package) == node.level + 1:
|
||||
|
@ -330,7 +334,10 @@ class HassImportsFormatChecker(BaseChecker): # type: ignore[misc]
|
|||
):
|
||||
self.add_message("hass-relative-import", node=node)
|
||||
return
|
||||
if self.current_package.startswith("homeassistant.components") and node.modname == "homeassistant.components":
|
||||
if (
|
||||
self.current_package.startswith("homeassistant.components")
|
||||
and node.modname == "homeassistant.components"
|
||||
):
|
||||
for name in node.names:
|
||||
if name[0] == self.current_package.split(".")[2]:
|
||||
self.add_message("hass-relative-import", node=node)
|
||||
|
|
Loading…
Add table
Reference in a new issue