Skip to content

[pre-commit.ci] pre-commit autoupdate #369

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

Merged
merged 3 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.4
rev: v0.11.5
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -45,7 +45,7 @@ repos:
exclude: tests/(eval|autofix)_files/.*_py(310|311).py

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.398
rev: v1.1.399
hooks:
- id: pyright
# ignore warnings about new version being available, no other warnings
Expand Down
10 changes: 5 additions & 5 deletions flake8_async/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import libcst as cst

from .base import Error, Options
from .visitors import (
ERROR_CLASSES,
ERROR_CLASSES_CST,
Expand All @@ -25,18 +26,17 @@

from libcst import Module

from .base import Error, Options
from .visitors.flake8asyncvisitor import Flake8AsyncVisitor, Flake8AsyncVisitor_cst


@dataclass
class SharedState:
options: Options
problems: list[Error] = field(default_factory=list)
noqas: dict[int, set[str]] = field(default_factory=dict)
problems: list[Error] = field(default_factory=list[Error])
noqas: dict[int, set[str]] = field(default_factory=dict[int, set[str]])
Comment on lines -35 to +36
Copy link
Member

Choose a reason for hiding this comment

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

huh, it seems like pyright needing this duplication of types might be an upstream issue?

Copy link
Member

@jakkdl jakkdl Apr 17, 2025

Choose a reason for hiding this comment

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

intended... microsoft/pyright#10277 (comment)

2025-04-17T22:30:41,090407337+02:00

so yeah hence me opening microsoft/pyright#10336

library: tuple[str, ...] = ()
typed_calls: dict[str, str] = field(default_factory=dict)
variables: dict[str, str] = field(default_factory=dict)
typed_calls: dict[str, str] = field(default_factory=dict[str, str])
variables: dict[str, str] = field(default_factory=dict[str, str])


class __CommonRunner:
Expand Down
40 changes: 28 additions & 12 deletions flake8_async/visitors/visitor91x.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,21 @@ class LoopState:
body_guaranteed_once: bool = False
has_break: bool = False

uncheckpointed_before_continue: set[Statement] = field(default_factory=set)
uncheckpointed_before_break: set[Statement] = field(default_factory=set)

artificial_errors: set[cst.Return | cst.Yield] = field(default_factory=set)
nodes_needing_checkpoints: list[cst.Return | cst.Yield | ArtificialStatement] = (
field(default_factory=list)
uncheckpointed_before_continue: set[Statement] = field(
default_factory=set[Statement]
)
uncheckpointed_before_break: set[Statement] = field(default_factory=set[Statement])
# pyright emits reportUnknownVariableType, requiring the generic to default_factory
# to be specified.
# But for these we require a union, and `|` doesn't work on py39, and uses of
# `Union` gets autofixed by ruff.
# So.... let's just ignore the error for now
artificial_errors: set[ # pyright: ignore[reportUnknownVariableType]
cst.Return | cst.Yield
] = field(default_factory=set)
nodes_needing_checkpoints: list[ # pyright: ignore[reportUnknownVariableType]
cst.Return | cst.Yield | ArtificialStatement
] = field(default_factory=list)

def copy(self):
return LoopState(
Expand All @@ -184,10 +192,14 @@ def copy(self):

@dataclass
class TryState:
body_uncheckpointed_statements: set[Statement] = field(default_factory=set)
try_checkpoint: set[Statement] = field(default_factory=set)
except_uncheckpointed_statements: set[Statement] = field(default_factory=set)
added: set[Statement] = field(default_factory=set)
body_uncheckpointed_statements: set[Statement] = field(
default_factory=set[Statement]
)
try_checkpoint: set[Statement] = field(default_factory=set[Statement])
except_uncheckpointed_statements: set[Statement] = field(
default_factory=set[Statement]
)
added: set[Statement] = field(default_factory=set[Statement])

def copy(self):
return TryState(
Expand All @@ -202,8 +214,12 @@ def copy(self):
class MatchState:
# TryState, LoopState, and MatchState all do fairly similar things. It would be nice
# to harmonize them and share logic.
base_uncheckpointed_statements: set[Statement] = field(default_factory=set)
case_uncheckpointed_statements: set[Statement] = field(default_factory=set)
base_uncheckpointed_statements: set[Statement] = field(
default_factory=set[Statement]
)
case_uncheckpointed_statements: set[Statement] = field(
default_factory=set[Statement]
)
has_fallback: bool = False

def copy(self):
Expand Down
Loading