- update to 24.9.0:

* Don't emit Y053 for long strings inside `Literal` slices or
  * metadata strings inside `Annotated` slices.
  * `flake8-pyi` no longer supports being run using Python 3.8.
    As a result, it not longer depends on the third-party
   `ast_decompiler` package.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-flake8-pyi?expand=0&rev=33
This commit is contained in:
Dirk Mueller 2024-10-29 21:16:10 +00:00 committed by Git OBS Bridge
commit 94197e409a
7 changed files with 535 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

3
flake8_pyi-24.6.0.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:74847fe88dba8dc3ccd27091dc5dcbe8993d7616214e4084f33afe469a675b14
size 61912

3
flake8_pyi-24.9.0.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:64fb735022958147afedd52781f263de337a34d118f3294ab2deb184f1c20cd9
size 61840

399
python-flake8-pyi.changes Normal file
View File

@ -0,0 +1,399 @@
-------------------------------------------------------------------
Tue Oct 29 21:15:28 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 24.9.0:
* Don't emit Y053 for long strings inside `Literal` slices or
* metadata strings inside `Annotated` slices.
* `flake8-pyi` no longer supports being run using Python 3.8.
As a result, it not longer depends on the third-party
`ast_decompiler` package.
-------------------------------------------------------------------
Sat Jun 15 15:36:11 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 24.6.0:
* Allow the use of `typing_extensions.TypeVar` in stubs.
* `typing_extensions.TypeVar` has the *default* parameter,
which only exists on Python 3.13+ when using `typing.TypeVar`.
* Reduce false positives from Y052 in relation to enum
subclasses.
* Declare support for Python 3.13
-------------------------------------------------------------------
Sat Apr 20 13:45:03 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 24.4.1:
* Y066: When using if/else with `sys.version_info`,
put the code for new Python versions first.
* Fix Y026 false positive: allow simple assignment to `None` in
class scopes if the class is known to be an enum class.
-------------------------------------------------------------------
Sun Apr 7 09:02:03 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 24.3.1:
* Y064: Use simpler syntax to define final literal types.
* For example, use `x: Final = 42` instead of `x:
Final[Literal[42]]`
* Y065: Don't use bare `Incomplete` in parameter and return
annotations.
* Y090: Fix false positive for `tuple[Unpack[Ts]]`.
-------------------------------------------------------------------
Mon Mar 25 17:31:54 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 24.3.0:
* Y063: Use PEP 570 syntax to mark positional-only arguments,
rather than the older Python 3.7-compatible syntax
described in PEP 484.
-------------------------------------------------------------------
Sat Jan 6 17:19:24 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 24.1.0:
* Y062: Disallow duplicate elements inside `Literal[]` slices.
* Support flake8>=7.0.0
* Y061 is no longer emitted in situations where Y062 would also
be emitted.
* Improve error message for Y060.
* Y023 now bans more imports from `typing_extensions` now that
typeshed has dropped support for Python 3.7.
* Y016: Fix false positive if a method had positional-only
parameters (using PEP 570 syntax and the first
positional-or-keyword parameter following the positional-only
parameters used a custom TypeVar (see #455).
* Y046: Fix false negative where an unused protocol would not
be detected if the protocol was generic.
-------------------------------------------------------------------
Tue Dec 5 21:07:25 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 23.11.0:
* Y058: Use `Iterator` rather than `Generator` as the return
value for simple `__iter__` methods, and `AsyncIterator` rather
than `AsyncGenerator` as the return value for simple `__aiter__`
methods.
* Y059: `Generic[]` should always be the last base class, if it
is present in the bases of a class.
* Y060, which flags redundant inheritance from `Generic[]`.
* Y061: Do not use `None` inside a `Literal[]` slice.
* For example, use `Literal["foo"] | None` instead of
`Literal["foo", None]`.
* Y022 and Y037 now flag more imports from `typing_extensions`.
* Y034 now attempts to avoid flagging methods inside classes
that inherit from `builtins.type`, `abc.ABCMeta` and/or
`enum.EnumMeta`. Classes that have one or more of these as
bases are metaclasses, and PEP 673 forbids the use of
`typing(_extensions).Self` for metaclasses.
* Attempting to import `typing_extensions.Text` now causes Y039
to be emitted rather than Y023.
* Y053 will no longer be emitted for the argument to
`@typing_extensions.deprecated`.
* Introduce Y090, which warns if you have an annotation such as
`tuple[int]` or `Tuple[int]`. These mean "a tuple of length 1,
in which the sole element is of type `int`". This is sometimes
what you want, but more usually you'll want `tuple[int, ...]`,
which means "a tuple of arbitrary (possibly 0) length, in
which all elements are of type `int`".
* Y011 now ignores `sentinel` and `_typeshed.sentinel` in
default values.
-------------------------------------------------------------------
Fri Aug 25 11:40:31 UTC 2023 - Markéta Machová <mmachova@suse.com>
- Update to 23.6.0
* Y011/Y014/Y015: Allow math constants math.inf, math.nan, math.e,
math.pi, math.tau, and their negatives in default values. Some
other semantically equivalent values, such as x = inf (from math
import inf), or x = np.inf (import numpy as np), should be rewritten
to x = math.inf.
* Y053: Disallow string or bytes literals with length >50 characters.
Previously this rule only applied to parameter default values;
it now applies everywhere.
* Y054: Disallow numeric literals with a string representation >10
characters long. Previously this rule only applied to parameter
default values; it now applies everywhere.
* Y055: Unions of the form type[X] | type[Y] can be simplified to type[X | Y].
* The way in which flake8-pyi modifies pyflakes runs has been improved.
* Introduce Y056: Various type checkers have different levels of support
for method calls on __all__. Use __all__ += ["foo", "bar"] instead,
as this is known to be supported by all major type checkers.
* Support Python 3.12
* Support PEP 695 syntax for declaring type aliases
* Introduce Y057: Do not use typing.ByteString or collections.abc.ByteString.
* flake8-pyi no longer supports being run on Python 3.7.
* flake8-pyi no longer supports being run with flake8 <v6.
-------------------------------------------------------------------
Mon Mar 6 15:53:17 UTC 2023 - Daniel Garcia <daniel.garcia@suse.com>
- Add set-tests-python-path.patch to fix tests inside osc build
environment, running the flake8 process with shell=True and forcing
the PYTHONPATH.
- Update to 23.1.2:
* Y011/Y014/Y015: Increase the maximum character length of literal
numbers in default values from 7 to 10, allowing hexadecimal
representation of 32-bit integers. Contributed by Avasam.
- 23.1.1
New error codes:
* Y052: Disallow default values in global or class namespaces where
the assignment does not have a type annotation. Stubs should be
explicit about the type of all variables in the stub; without type
annotations, the type checker is forced to make inferences, which
may have unpredictable consequences. Enum members are excluded
from this check, as are various special assignments such as
__all__ and __match_args__.
Other changes:
* Disallow numeric default values where len(str(default)) > 7. If a
function has a default value where the string representation is
greater than 7 characters, it is likely to be an implementation
detail or a constant that varies depending on the system you're
running on, such as sys.maxsize.
* Disallow str or bytes defaults where the default is >50 characters
long, for similar reasons.
* Allow ast.Attribute nodes as default values for a small number of
special cases, such as sys.maxsize and sys.executable.
* Fewer Y020 false positives are now emitted when encountering
default values in stub files.
- 23.1.0
Bugfixes:
* Do not emit Y020 (quoted annotations) for strings in parameter defaults.
* Fix checking of defaults for functions with positional-only parameters.
Other changes:
* Modify Y036 so that _typeshed.Unused is allowed as an annotation
for parameters in __(a)exit__ methods. Contributed by Avasam
* Several changes have been made to error codes relating to imports:
- The Y027 error code has been removed.
- All errors that used to result in Y027 being emitted now result
in Y022 being emitted instead.
- Some errors that used to result in Y023 being emitted now result
in Y022 being emitted instead.
- typing.Match and typing.Pattern have been added to the list of
imports banned by Y022. Use re.Match and re.Pattern instead.
* flake8-pyi no longer supports stub files that aim to support
Python 2. If your stubs need to support Python 2, pin flake8-pyi
to 22.11.0 or lower.
* Y011, Y014 and Y015 have all been significantly relaxed. None,
bools, ints, floats, complex numbers, strings and bytes are all
now allowed as default values for parameter annotations or
assignments.
* Hatchling is now used as the build backend. This should have
minimal, if any, user-facing impact.
-------------------------------------------------------------------
Tue Dec 6 03:30:37 UTC 2022 - Yogalakshmi Arunachalam <yarunachalam@suse.com>
- Update to version 22.11.0:
* Bugfixes:
Specify encoding when opening files. Prevents UnicodeDecodeError on Windows when the file contains non-CP1252 characters. Contributed by Avasam.
Significant changes have been made to the Y041 check. Previously, Y041 flagged "redundant numeric unions"
(e.g. float | int, complex | float or complex | int) in all contexts outside of type aliases. This was incorrect.
PEP 484 only specifies that type checkers should treat int as an implicit subtype of float in the specific context of parameter annotations
for functions and methods. Y041 has therefore been revised to only emit errors on "redundant numeric unions" in the context of parameter annotations.
* Other changes:
Support running with flake8 v6.
-------------------------------------------------------------------
Fri Nov 4 15:45:00 UTC 2022 - Daniel Garcia <daniel.garcia@suse.com>
- Remove LICENSE source, it's now in the release
- Remove python_module macro definition
- Update to 22.10.0:
# Bugfixes:
- Do not emit Y020 for empty strings. Y020 concerns "quoted annotations",
- but an empty string can never be a quoted annotation.
- Add special-casing so that Y020 is not emitted for __slots__ definitions
- inside class blocks.
- Expand Y035 to cover __slots__ definitions as well as __match_args__ and
- __all__ definitions.
- Expand Y015 so that errors are emitted for assignments to negative numbers.
# Other changes:
- Since v22.8.1, flake8-pyi has emitted a FutureWarning if run with flake8<5,
warning that the plugin would soon become incompatible with flake8<5. Due
to some issues that mean that some users are unable to upgrade to
flake8>=5, however, flake8-pyi no longer intends to remove support for
running the plugin with flake8<5 before Python 3.7 has reached end-of-life.
As such, the FutureWarning is no longer emitted.
- 22.8.2:
# New error codes:
- Y047: Detect unused TypeAlias declarations.
- Y049: Detect unused TypedDict definitions.
- Y050: Prefer typing_extensions.Never for argument annotations over
typing.NoReturn.
- Y051: Detect redundant unions between Literal types and builtin supertypes
(e.g. Literal["foo"] | str, or Literal[5] | int).
# Other enhancements:
- Support mypy_extensions.TypedDict.
- 22.8.1:
- Add support for flake8 >= 5.0.0.
- 22.8.0:
# New error codes:
- Y046: Detect unused Protocols.
- Y048: Function bodies should contain exactly one statement.
# Bugfixes:
- Improve error message for the case where a function body contains a
docstring and a ... or pass statement.
# Other changes:
- Pin required flake8 version to <5.0.0 (flake8-pyi is not currently
compatible with flake8 5.0.0).
- 22.7.0
# New error codes:
- Introduce Y041: Ban redundant numeric unions (int | float, int | complex,
float | complex).
- Introduce Y042: Type alias names should use CamelCase rather than
snake_case
- Introduce Y043: Ban type aliases from having names ending with an uppercase
"T".
- Introduce Y044: Discourage unnecessary from __future__ import annotations
import. Contributed by Torsten Wörtwein.
- Introduce Y045: Ban returning (Async)Iterable from __(a)iter__ methods.
# Other enhancements and behaviour changes:
- Improve error message for Y026 check.
- Expand Y026 check. Since version 22.4.0, this has only emitted an error for
assignments to typing.Literal, typing.Union, and PEP 604 unions. It now
also emits an error for any subscription on the right-hand side of a simple
assignment, as well as for assignments to typing.Any and None.
- Support typing_extensions.overload and typing_extensions.NamedTuple.
- Slightly expand Y034 to cover the case where a class inheriting from
(Async)Iterator returns (Async)Iterable from __(a)iter__. These classes
should nearly always return Self from these methods.
- Support Python 3.11.
- 22.5.1:
# Behaviour changes:
- Relax Y020 check slightly, enabling the idiom __all__ += ["foo", "bar"] to
be used in a stub file.
- 22.5.0:
# Features:
- Introduce Y039: Use str instead of typing.Text for Python 3 stubs.
- Teach the Y036 check that builtins.object (as well as the unqualified
object) is acceptable as an annotation for an __(a)exit__ method argument.
- Teach the Y029 check to emit errors for __repr__ and __str__ methods that
return builtins.str (as opposed to the unqualified str).
- Introduce Y040: Never explicitly inherit from object in Python 3 stubs.
- 22.4.1:
# Features:
- Expand Y027 check to prohibit importing any objects from the typing module
that are aliases for objects living collections.abc (except for
typing.AbstractSet, which is special-cased).
- Introduce Y038: Use from collections.abc import Set as AbstractSet instead
of from typing import AbstractSet.
# Bugfixes:
- Improve inaccurate error messages for Y036.
- 22.4.0:
# Features:
- Introduce Y036 (check for badly defined __exit__ and __aexit__ methods).
- Introduce Y037 (Use PEP 604 syntax instead of typing.Union and
typing.Optional). Contributed by Oleg Höfling.
# Behaviour changes:
- Expand Y035 to cover __match_args__ inside class definitions, as well as
__all__ in the global scope.
# Bugfixes:
- Improve Y026 check (regarding typing.TypeAlias) to reduce false-positive
errors emitted when the plugin encountered variable aliases in a stub file.
- 22.3.0:
# Bugfixes:
- fix bug where incorrect quoted annotations were not detected within if
blocks
# Behaviour changes:
- Add special-casing so that string literals are allowed in the context of
__match_args__ assignments inside a class definition.
- Add special-casing so that arbitrary values can be assigned to a variable
in a stub file if the variable is annotated with Final.
- 22.2.0:
# Bugfixes:
- fix bugs in several error codes so that e.g. _T = typing.TypeVar("_T") is
recognised as a TypeVar definition (previously only _T = TypeVar("_T") was
recognised).
- fix bug where foo = False at the module level did not trigger a Y015 error.
- fix bug where TypeVars were erroneously flagged as unused if they were only
used in a typing.Union subscript.
- improve unclear error messages for Y022, Y023 and Y027 error codes.
# Features:
- introduce Y032 (prefer object to Any for the second argument in __eq__ and
__ne__ methods).
- introduce Y033 (always use annotations in stubs, rather than type
comments).
- introduce Y034 (detect common errors where return types are hardcoded, but
they should use TypeVars instead).
- introduce Y035 (__all__ in a stub has the same semantics as at runtime).
- 22.1.0:
- extend Y001 to cover ParamSpec and TypeVarTuple in addition to TypeVar
- detect usage of non-integer indices in sys.version_info checks
- extend Y010 to check async functions in addition to normal functions
- extend Y010 to cover what was previously included in Y090 (disallow
assignments in __init__ methods) and Y091 (disallow raise statements). The
previous checks were disabled by default.
- introduce Y016 (duplicate union member)
- introduce Y017 (disallows assignments with multiple targets or non-name
targets)
- introduce Y018 (detect unused TypeVars)
- introduce Y019 (detect TypeVars that should be _typeshed.Self, but aren't)
- introduce Y020 (never use quoted annotations in stubs)
- introduce Y021 (docstrings should not be included in stubs)
- introduce Y022 (prefer stdlib classes over typing aliases)
- introduce Y023 (prefer typing over typing_extensions)
- introduce Y024 (prefer typing.NamedTuple to collections.namedtuple)
- introduce Y026 (require using TypeAlias for type aliases)
- introduce Y025 (always alias collections.abc.Set)
- introduce Y027 (Python 2-incompatible extension of Y022)
- introduce Y028 (Use class-based syntax for NamedTuples)
- introduce Y029 (never define __repr__ or __str__)
- introduce Y030 (use Literal['foo', 'bar'] instead of Literal['foo'] |
Literal['bar'])
- introduce Y031 (use class-based syntax for TypedDicts where possible)
- all errors are now enabled by default
- remove Y092 (top-level attribute must not have a default value)
- attrs is no longer a dependency
- ast_decompiler has been added as a dependency on Python 3.8 and 3.7
- support Python 3.10
- discontinue support for Python 3.6
-------------------------------------------------------------------
Tue May 4 06:41:27 UTC 2021 - Markéta Machová <mmachova@suse.com>
- Update to 20.10.0
* Fix for Python 3.9's AST changes
* skip typeshed test for older Python versions
-------------------------------------------------------------------
Fri May 15 21:22:02 UTC 2020 - Benjamin Greiner <code@bnavigator.de>
- Update to v20.5.0
* support flake8 3.8.0
* introduce Y091 (function body must not contain "raise")
* introduce Y015 (attribute must not have a default value other than "...")
* introduce Y092 (top-level attribute must not have a default value)
-------------------------------------------------------------------
Thu Mar 7 16:34:17 UTC 2019 - John Vandenberg <jayvdb@gmail.com>
- Fix python base dependency to allow on Python 3.6
- Make dependency on python-typing explicit
- Update to v19.3.0
- Set pyflakes minimum dependency
- Blacken source
-------------------------------------------------------------------
Thu Feb 28 09:43:51 UTC 2019 - John Vandenberg <jayvdb@gmail.com>
- Remove workaround for two previously failing tests fixed upstream
- Add build dependency on Python 3.6+
- Add LICENSE
- Udpate to v19.2.0
* Support 3.7
* Be explicit in setup.py about Python 3.6+
* add `.flake8` to manifest file
* Use --stdin-display-name as filename when reading from stdin
* Add rules for checking an empty class
* Add a check for non-ellipsis, non-typed arguments
* Coding style improvements
-------------------------------------------------------------------
Sat Dec 8 21:23:56 UTC 2018 - Matej Cepl <mcepl@suse.com>
- Use tarball from the master as of 2018-12-08 to test #16
-------------------------------------------------------------------
Tue Oct 23 09:47:05 UTC 2018 - Matej Cepl <mcepl@suse.com>
- Initial packaging effort for flake8-pyi 18.3.1

83
python-flake8-pyi.spec Normal file
View File

@ -0,0 +1,83 @@
#
# spec file for package python-flake8-pyi
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?sle15_python_module_pythons}
Name: python-flake8-pyi
Version: 24.9.0
Release: 0
Summary: A plugin for flake8 to enable linting .pyi files
License: MIT
Group: Development/Languages/Python
URL: https://github.com/ambv/flake8-pyi
Source: https://files.pythonhosted.org/packages/source/f/flake8-pyi/flake8_pyi-%{version}.tar.gz
# PATCH-FIX-OPENSUSE set-tests-python-path.patch, patch to fix
# PYTHONPATH resolution for tests running inside osc
Patch0: set-tests-python-path.patch
BuildRequires: %{python_module base >= 3.8.0}
BuildRequires: %{python_module hatch_vcs}
BuildRequires: %{python_module hatchling}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module wheel}
BuildRequires: python-rpm-macros
# SECTION test requirements
BuildRequires: %{python_module attrs}
BuildRequires: %{python_module flake8 >= 6.0.0}
BuildRequires: %{python_module pyflakes >= 2.1.1}
# Use pytest directly to bypass setup.py test dependencies
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module black}
BuildRequires: %{python_module flake8-bugbear}
BuildRequires: %{python_module pytest-xdist}
BuildRequires: %{python_module typing}
# /SECTION
BuildRequires: fdupes
Requires: python-attrs
Requires: python-base >= 3.8.0
Requires: python-flake8 >= 6.0.0
Requires: python-pyflakes >= 2.1.1
Requires: python-typing
BuildArch: noarch
%python_subpackages
%description
A plugin for Flake8 that provides specializations for type hinting stub
files. Especially interesting for linting typeshed.
%prep
%autosetup -p1 -n flake8_pyi-%{version}
sed -i '1{\,^#!%{_bindir}/env python,d}' pyi.py
%build
%pyproject_wheel
%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest -v tests
%files %{python_files}
%license LICENSE
%doc README.md
%{python_sitelib}/pyi.py*
%{pycache_only %{python_sitelib}/__pycache__/pyi.*.py*}
%{python_sitelib}/flake8_pyi-%{version}*-info
%changelog

View File

@ -0,0 +1,23 @@
Index: flake8_pyi-23.11.0/tests/test_pyi_files.py
===================================================================
--- flake8_pyi-23.11.0.orig/tests/test_pyi_files.py
+++ flake8_pyi-23.11.0/tests/test_pyi_files.py
@@ -43,6 +43,9 @@ def test_pyi_file(path: str) -> None:
option = flag.split("=")[0]
assert option not in {"--ignore", "--select"}, bad_flag_msg(option[2:])
+ pythonpath = os.environ.get("PYTHONPATH")
+ pythonpath = f"PYTHONPATH={pythonpath}:."
+
# Silence DeprecationWarnings from our dependencies (pyflakes, flake8-bugbear, etc.)
#
# For DeprecationWarnings coming from flake8-pyi itself,
@@ -51,6 +54,8 @@ def test_pyi_file(path: str) -> None:
# but the test failure report that pytest gives is much easier to read
# if we use `-Wdefault:::pyi`
flake8_invocation = [
+ "env",
+ pythonpath,
sys.executable,
"-Wignore",
"-Wdefault:::pyi",