Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 22, 2024
1 parent bae028b commit 46d1557
Show file tree
Hide file tree
Showing 64 changed files with 80 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bin/gen-pycodestyle-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Call(NamedTuple):
return cls(func.__name__, inspect.isgeneratorfunction(func), params)


def lines() -> Generator[str, None, None]:
def lines() -> Generator[str]:
logical = []
physical = []

Expand Down
1 change: 1 addition & 0 deletions example-plugin/src/flake8_example_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for an example Flake8 plugin."""

from __future__ import annotations

from .off_by_default import ExampleTwo
Expand Down
1 change: 1 addition & 0 deletions example-plugin/src/flake8_example_plugin/off_by_default.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Our first example plugin."""

from __future__ import annotations


Expand Down
1 change: 1 addition & 0 deletions example-plugin/src/flake8_example_plugin/on_by_default.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Our first example plugin."""

from __future__ import annotations


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ install_requires =
mccabe>=0.7.0,<0.8.0
pycodestyle>=2.12.0,<2.13.0
pyflakes>=3.2.0,<3.3.0
python_requires = >=3.8.1
python_requires = >=3.9
package_dir =
=src

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Packaging logic for Flake8."""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions src/flake8/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.. autofunction:: flake8.configure_logging
"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions src/flake8/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module allowing for ``python -m flake8 ...``."""

from __future__ import annotations

from flake8.main.cli import main
Expand Down
1 change: 1 addition & 0 deletions src/flake8/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
This is the only submodule in Flake8 with a guaranteed stable API. All other
submodules are considered internal only and are subject to change.
"""

from __future__ import annotations
1 change: 1 addition & 0 deletions src/flake8/api/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Previously, users would import :func:`get_style_guide` from ``flake8.engine``.
In 3.0 we no longer have an "engine" module but we maintain the API from it.
"""

from __future__ import annotations

import argparse
Expand Down
3 changes: 2 additions & 1 deletion src/flake8/checker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Checker Manager and Checker classes."""

from __future__ import annotations

import argparse
Expand Down Expand Up @@ -53,7 +54,7 @@
@contextlib.contextmanager
def _mp_prefork(
plugins: Checkers, options: argparse.Namespace
) -> Generator[None, None, None]:
) -> Generator[None]:
# we can save significant startup work w/ `fork` multiprocessing
global _mp_plugins, _mp_options
_mp_plugins, _mp_options = plugins, options
Expand Down
1 change: 1 addition & 0 deletions src/flake8/defaults.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants that define defaults."""

from __future__ import annotations

import re
Expand Down
5 changes: 3 additions & 2 deletions src/flake8/discover_files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions related to discovering paths."""

from __future__ import annotations

import logging
Expand All @@ -16,7 +17,7 @@ def _filenames_from(
arg: str,
*,
predicate: Callable[[str], bool],
) -> Generator[str, None, None]:
) -> Generator[str]:
"""Generate filenames from an argument.
:param arg:
Expand Down Expand Up @@ -55,7 +56,7 @@ def expand_paths(
stdin_display_name: str,
filename_patterns: Sequence[str],
exclude: Sequence[str],
) -> Generator[str, None, None]:
) -> Generator[str]:
"""Expand out ``paths`` from commandline to the lintable files."""
if not paths:
paths = ["."]
Expand Down
1 change: 1 addition & 0 deletions src/flake8/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Exception classes for all of Flake8."""

from __future__ import annotations


Expand Down
1 change: 1 addition & 0 deletions src/flake8/formatting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Submodule containing the default formatters for Flake8."""

from __future__ import annotations
1 change: 1 addition & 0 deletions src/flake8/formatting/_windows_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
See: https://github.com/pre-commit/pre-commit/blob/cb40e96/pre_commit/color.py
"""

from __future__ import annotations

import sys
Expand Down
1 change: 1 addition & 0 deletions src/flake8/formatting/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The base class and interface for all formatting plugins."""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions src/flake8/formatting/default.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Default formatting class for Flake8."""

from __future__ import annotations

from flake8.formatting import base
Expand Down
1 change: 1 addition & 0 deletions src/flake8/main/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Module containing the logic for the Flake8 entry-points."""

from __future__ import annotations
1 change: 1 addition & 0 deletions src/flake8/main/application.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing the application logic for Flake8."""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions src/flake8/main/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command-line implementation of flake8."""

from __future__ import annotations

import sys
Expand Down
1 change: 1 addition & 0 deletions src/flake8/main/debug.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing the logic for our debugging logic."""

from __future__ import annotations

import platform
Expand Down
1 change: 1 addition & 0 deletions src/flake8/main/options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the logic for all of the default options for Flake8."""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions src/flake8/options/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
to aggregate configuration into one object used by plugins and Flake8.
"""

from __future__ import annotations
1 change: 1 addition & 0 deletions src/flake8/options/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This holds the logic that uses the collected and merged config files and
applies the user-specified command-line configuration on top of it.
"""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions src/flake8/options/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Config handling logic for Flake8."""

from __future__ import annotations

import configparser
Expand Down
1 change: 1 addition & 0 deletions src/flake8/options/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Option handling and Option management logic."""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions src/flake8/options/parse_args.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Procedure for parsing args, config, loading plugins."""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions src/flake8/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Submodule of built-in plugins and plugin managers."""

from __future__ import annotations
9 changes: 5 additions & 4 deletions src/flake8/plugins/finder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions related to finding and loading plugins."""

from __future__ import annotations

import configparser
Expand Down Expand Up @@ -68,7 +69,7 @@ class Plugins(NamedTuple):
reporters: dict[str, LoadedPlugin]
disabled: list[LoadedPlugin]

def all_plugins(self) -> Generator[LoadedPlugin, None, None]:
def all_plugins(self) -> Generator[LoadedPlugin]:
"""Return an iterator over all :class:`LoadedPlugin`s."""
yield from self.checkers.tree
yield from self.checkers.logical_line
Expand Down Expand Up @@ -151,7 +152,7 @@ def _flake8_plugins(
eps: Iterable[importlib.metadata.EntryPoint],
name: str,
version: str,
) -> Generator[Plugin, None, None]:
) -> Generator[Plugin]:
pyflakes_meta = importlib.metadata.distribution("pyflakes").metadata
pycodestyle_meta = importlib.metadata.distribution("pycodestyle").metadata

Expand All @@ -173,7 +174,7 @@ def _flake8_plugins(
yield Plugin(name, version, ep)


def _find_importlib_plugins() -> Generator[Plugin, None, None]:
def _find_importlib_plugins() -> Generator[Plugin]:
# some misconfigured pythons (RHEL) have things on `sys.path` twice
seen = set()
for dist in importlib.metadata.distributions():
Expand Down Expand Up @@ -212,7 +213,7 @@ def _find_importlib_plugins() -> Generator[Plugin, None, None]:

def _find_local_plugins(
cfg: configparser.RawConfigParser,
) -> Generator[Plugin, None, None]:
) -> Generator[Plugin]:
for plugin_type in ("extension", "report"):
group = f"flake8.{plugin_type}"
for plugin_s in utils.parse_comma_separated_list(
Expand Down
5 changes: 3 additions & 2 deletions src/flake8/plugins/pycodestyle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generated using ./bin/gen-pycodestyle-plugin."""

# fmt: off
from __future__ import annotations

Expand Down Expand Up @@ -55,7 +56,7 @@ def pycodestyle_logical(
previous_unindented_logical_line: Any,
tokens: Any,
verbose: Any,
) -> Generator[tuple[int, str], None, None]:
) -> Generator[tuple[int, str]]:
"""Run pycodestyle logical checks."""
yield from _ambiguous_identifier(logical_line, tokens)
yield from _bare_except(logical_line, noqa)
Expand Down Expand Up @@ -93,7 +94,7 @@ def pycodestyle_physical(
noqa: Any,
physical_line: Any,
total_lines: Any,
) -> Generator[tuple[int, str], None, None]:
) -> Generator[tuple[int, str]]:
"""Run pycodestyle physical checks."""
ret = _maximum_line_length(physical_line, max_line_length, multiline, line_number, noqa) # noqa: E501
if ret is not None:
Expand Down
3 changes: 2 additions & 1 deletion src/flake8/plugins/pyflakes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Plugin built-in to Flake8 to treat pyflakes as a plugin."""

from __future__ import annotations

import argparse
Expand Down Expand Up @@ -97,7 +98,7 @@ def parse_options(cls, options: argparse.Namespace) -> None:
cls.builtIns = cls.builtIns.union(options.builtins)
cls.with_doctest = options.doctests

def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]:
def run(self) -> Generator[tuple[int, int, str, type[Any]]]:
"""Run the plugin."""
for message in self.messages:
col = getattr(message, "col", 0)
Expand Down
1 change: 1 addition & 0 deletions src/flake8/plugins/reporter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for constructing the requested report plugin."""

from __future__ import annotations

import argparse
Expand Down
7 changes: 3 additions & 4 deletions src/flake8/processor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing our file processor that tokenizes a file for checks."""

from __future__ import annotations

import argparse
Expand Down Expand Up @@ -127,9 +128,7 @@ def fstring_start(self, lineno: int) -> None: # pragma: >=3.12 cover
"""Signal the beginning of an fstring."""
self._fstring_start = lineno

def multiline_string(
self, token: tokenize.TokenInfo
) -> Generator[str, None, None]:
def multiline_string(self, token: tokenize.TokenInfo) -> Generator[str]:
"""Iterate through the lines of a multiline string."""
if token.type == FSTRING_END: # pragma: >=3.12 cover
start = self._fstring_start
Expand Down Expand Up @@ -263,7 +262,7 @@ def keyword_arguments_for(
)
return ret

def generate_tokens(self) -> Generator[tokenize.TokenInfo, None, None]:
def generate_tokens(self) -> Generator[tokenize.TokenInfo]:
"""Tokenize the file and yield the tokens."""
for token in tokenize.generate_tokens(self.next_line):
if token[2][0] > self.total_lines:
Expand Down
3 changes: 2 additions & 1 deletion src/flake8/statistics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Statistic collection logic for Flake8."""

from __future__ import annotations

from typing import Generator
Expand Down Expand Up @@ -36,7 +37,7 @@ def record(self, error: Violation) -> None:

def statistics_for(
self, prefix: str, filename: str | None = None
) -> Generator[Statistic, None, None]:
) -> Generator[Statistic]:
"""Generate statistics for the prefix and filename.
If you have a :class:`Statistics` object that has recorded errors,
Expand Down
11 changes: 4 additions & 7 deletions src/flake8/style_guide.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of the StyleGuide used by Flake8."""

from __future__ import annotations

import argparse
Expand Down Expand Up @@ -231,7 +232,7 @@ def __init__(

def populate_style_guides_with(
self, options: argparse.Namespace
) -> Generator[StyleGuide, None, None]:
) -> Generator[StyleGuide]:
"""Generate style guides from the per-file-ignores option.
:param options:
Expand All @@ -253,9 +254,7 @@ def _style_guide_for(self, filename: str) -> StyleGuide:
)

@contextlib.contextmanager
def processing_file(
self, filename: str
) -> Generator[StyleGuide, None, None]:
def processing_file(self, filename: str) -> Generator[StyleGuide]:
"""Record the fact that we're processing the file's results."""
guide = self.style_guide_for(filename)
with guide.processing_file(filename):
Expand Down Expand Up @@ -338,9 +337,7 @@ def copy(
)

@contextlib.contextmanager
def processing_file(
self, filename: str
) -> Generator[StyleGuide, None, None]:
def processing_file(self, filename: str) -> Generator[StyleGuide]:
"""Record the fact that we're processing the file's results."""
self.formatter.beginning(filename)
yield self
Expand Down
1 change: 1 addition & 0 deletions src/flake8/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility methods for flake8."""

from __future__ import annotations

import fnmatch as _fnmatch
Expand Down
1 change: 1 addition & 0 deletions src/flake8/violation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the Violation error class used internally."""

from __future__ import annotations

import functools
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""This is here because mypy doesn't understand PEP 420."""

from __future__ import annotations
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test configuration for py.test."""

from __future__ import annotations

import sys
Expand Down
Loading

0 comments on commit 46d1557

Please sign in to comment.