From c01786b035cd7973b03871682a0add93fd44d751 Mon Sep 17 00:00:00 2001 From: Matt Norton Date: Thu, 9 Oct 2025 18:26:02 +0100 Subject: [PATCH] Plugin parameters inspection for Python 3.14 With the release of Python 3.14, many runtime annotations can now be declared without strings. If they are evaluated then `NameError`s will occur. Inspecting the callable signature of a plugin only requires the parameters' `name`s and `default`, so the annotations can be ignored and the inspection `annotation_format` can be set to `Format.STRING` (so long as `eval_str` is also `False` like it is by default). See https://docs.python.org/3.14/library/inspect.html#inspect.signature & https://docs.python.org/3.14/library/annotationlib.html#annotationlib.Format.STRING --- src/flake8/plugins/finder.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/flake8/plugins/finder.py b/src/flake8/plugins/finder.py index 4da3402..5239271 100644 --- a/src/flake8/plugins/finder.py +++ b/src/flake8/plugins/finder.py @@ -1,6 +1,7 @@ """Functions related to finding and loading plugins.""" from __future__ import annotations +import annotationlib import configparser import importlib.metadata import inspect @@ -276,7 +277,9 @@ def _parameters_for(func: Any) -> dict[str, bool]: parameters = { parameter.name: parameter.default is inspect.Parameter.empty - for parameter in inspect.signature(func).parameters.values() + for parameter in inspect.signature( + func, annotation_format=annotationlib.Format.STRING + ).parameters.values() if parameter.kind is inspect.Parameter.POSITIONAL_OR_KEYWORD }