diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0edd273..b7a7e07 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ ci: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.3 + rev: v0.12.4 hooks: - id: ruff args: [--fix] @@ -38,7 +38,7 @@ repos: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.16.1 + rev: v1.17.0 hooks: - id: mypy # uses py311 syntax, mypy configured for py39 diff --git a/flake8_async/visitors/flake8asyncvisitor.py b/flake8_async/visitors/flake8asyncvisitor.py index 7bce4a9..46b236c 100644 --- a/flake8_async/visitors/flake8asyncvisitor.py +++ b/flake8_async/visitors/flake8asyncvisitor.py @@ -16,9 +16,7 @@ from ..runner import SharedState - HasLineCol = Union[ - ast.expr, ast.stmt, ast.arg, ast.excepthandler, ast.alias, Statement - ] + HasLineCol = Union[ast.expr, ast.stmt, ast.arg, ast.excepthandler, Statement] class Flake8AsyncVisitor(ast.NodeVisitor, ABC): diff --git a/flake8_async/visitors/helpers.py b/flake8_async/visitors/helpers.py index 7821dcd..ea2da3d 100644 --- a/flake8_async/visitors/helpers.py +++ b/flake8_async/visitors/helpers.py @@ -6,6 +6,7 @@ from __future__ import annotations import ast +from collections.abc import Sized from dataclasses import dataclass from fnmatch import fnmatch from typing import TYPE_CHECKING, Generic, TypeVar, Union @@ -140,14 +141,9 @@ def iter_guaranteed_once(iterable: ast.expr) -> bool: else: return True return False - # once we drop 3.9 we can add `and not isinstance(iterable.value, types.EllipsisType)` - # to get rid of `type: ignore`. Or just live with the fact that pyright doesn't - # make use of the `hasattr`. + if isinstance(iterable, ast.Constant): - return ( - hasattr(iterable.value, "__len__") - and len(iterable.value) > 0 # pyright: ignore[reportArgumentType] - ) + return isinstance(iterable.value, Sized) and len(iterable.value) > 0 if isinstance(iterable, ast.Dict): for key, val in zip(iterable.keys, iterable.values):