Compare commits
10 Commits
38ec77ebe0
...
0054644eeb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0054644eeb | ||
|
|
6935da6658 | ||
|
|
b494f9043d | ||
|
|
aadab8c411 | ||
|
|
b478ae0fd1 | ||
|
|
74cb1644cc | ||
|
|
323958811f | ||
|
|
0581305331 | ||
|
|
9ef0855855 | ||
|
|
31fa51782b |
@ -0,0 +1,75 @@
|
||||
From 13cad915e6b181b2f6a85efc2ead4856b23bccc0 Mon Sep 17 00:00:00 2001
|
||||
From: Angus L'Herrou <piraka@brandeis.edu>
|
||||
Date: Tue, 5 Oct 2021 18:44:29 -0400
|
||||
Subject: [PATCH] Detect typing module attributes with 'import typing as
|
||||
<name>' (#632)
|
||||
|
||||
* added functionality to detect typing module attributes with 'import typing as <name>'
|
||||
|
||||
* remove async keyword from test_aliased_import
|
||||
---
|
||||
pyflakes/checker.py | 12 +++++++++++-
|
||||
pyflakes/test/test_type_annotations.py | 17 +++++++++++++++++
|
||||
2 files changed, 28 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
|
||||
index 6fafe89..45c7a4a 100644
|
||||
--- a/pyflakes/checker.py
|
||||
+++ b/pyflakes/checker.py
|
||||
@@ -720,6 +720,16 @@ def _is_typing_helper(node, is_name_match_fn, scope_stack):
|
||||
|
||||
return False
|
||||
|
||||
+ def _module_scope_is_typing(name):
|
||||
+ for scope in reversed(scope_stack):
|
||||
+ if name in scope:
|
||||
+ return (
|
||||
+ isinstance(scope[name], Importation) and
|
||||
+ scope[name].fullName in TYPING_MODULES
|
||||
+ )
|
||||
+
|
||||
+ return False
|
||||
+
|
||||
return (
|
||||
(
|
||||
isinstance(node, ast.Name) and
|
||||
@@ -727,7 +737,7 @@ def _is_typing_helper(node, is_name_match_fn, scope_stack):
|
||||
) or (
|
||||
isinstance(node, ast.Attribute) and
|
||||
isinstance(node.value, ast.Name) and
|
||||
- node.value.id in TYPING_MODULES and
|
||||
+ _module_scope_is_typing(node.value.id) and
|
||||
is_name_match_fn(node.attr)
|
||||
)
|
||||
)
|
||||
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
|
||||
index 6a66bcd..f3b6c24 100644
|
||||
--- a/pyflakes/test/test_type_annotations.py
|
||||
+++ b/pyflakes/test/test_type_annotations.py
|
||||
@@ -121,6 +121,23 @@ class TestTypeAnnotations(TestCase):
|
||||
def f(self, x): return x
|
||||
""")
|
||||
|
||||
+ def test_aliased_import(self):
|
||||
+ """Detect when typing is imported as another name"""
|
||||
+ self.flakes("""
|
||||
+ import typing as t
|
||||
+
|
||||
+ @t.overload
|
||||
+ def f(s): # type: (None) -> None
|
||||
+ pass
|
||||
+
|
||||
+ @t.overload
|
||||
+ def f(s): # type: (int) -> int
|
||||
+ pass
|
||||
+
|
||||
+ def f(s):
|
||||
+ return s
|
||||
+ """)
|
||||
+
|
||||
def test_not_a_typing_overload(self):
|
||||
"""regression test for @typing.overload detection bug in 2.1.0"""
|
||||
self.flakes("""
|
||||
--
|
||||
2.42.0.windows.2
|
||||
|
||||
42
0001-remove-old-and-unused-tracing-code-625.patch
Normal file
42
0001-remove-old-and-unused-tracing-code-625.patch
Normal file
@ -0,0 +1,42 @@
|
||||
From da197ee94e791640d82940396c19d2d82ca8defb Mon Sep 17 00:00:00 2001
|
||||
From: Terence Honles <terence@honles.com>
|
||||
Date: Thu, 20 May 2021 07:47:19 -0700
|
||||
Subject: [PATCH] remove old and unused "tracing" code (#625)
|
||||
|
||||
---
|
||||
pyflakes/checker.py | 5 -----
|
||||
1 file changed, 5 deletions(-)
|
||||
|
||||
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
|
||||
index 48d3841..135ad33 100644
|
||||
--- a/pyflakes/checker.py
|
||||
+++ b/pyflakes/checker.py
|
||||
@@ -868,7 +868,6 @@ class Checker(object):
|
||||
|
||||
nodeDepth = 0
|
||||
offset = None
|
||||
- traceTree = False
|
||||
_in_annotation = AnnotationState.NONE
|
||||
_in_deferred = False
|
||||
|
||||
@@ -1393,8 +1392,6 @@ class Checker(object):
|
||||
if self.offset and getattr(node, 'lineno', None) is not None:
|
||||
node.lineno += self.offset[0]
|
||||
node.col_offset += self.offset[1]
|
||||
- if self.traceTree:
|
||||
- print(' ' * self.nodeDepth + node.__class__.__name__)
|
||||
if self.futuresAllowed and not (isinstance(node, ast.ImportFrom) or
|
||||
self.isDocstring(node)):
|
||||
self.futuresAllowed = False
|
||||
@@ -1406,8 +1403,6 @@ class Checker(object):
|
||||
handler(node)
|
||||
finally:
|
||||
self.nodeDepth -= 1
|
||||
- if self.traceTree:
|
||||
- print(' ' * self.nodeDepth + 'end ' + node.__class__.__name__)
|
||||
|
||||
_getDoctestExamples = doctest.DocTestParser().get_examples
|
||||
|
||||
--
|
||||
2.42.0.windows.2
|
||||
|
||||
Binary file not shown.
BIN
pyflakes-2.3.1.tar.gz
Normal file
BIN
pyflakes-2.3.1.tar.gz
Normal file
Binary file not shown.
156
pyflakes.spec
156
pyflakes.spec
@ -1,106 +1,106 @@
|
||||
Name: pyflakes
|
||||
Version: 2.1.0
|
||||
Release: 1
|
||||
Summary: A simple program which checks Python source files for errors
|
||||
%global _empty_manifest_terminate_build 0
|
||||
%global common_desc \
|
||||
Pyflakes A simple program which checks Python source files for errors.Pyflakes
|
||||
Name: python-pyflakes
|
||||
Version: 2.3.1
|
||||
Release: 5
|
||||
Summary: passive checker of Python programs
|
||||
License: MIT
|
||||
URL: https://github.com/PyCQA/pyflakes
|
||||
Source0: https://files.pythonhosted.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz
|
||||
Source1: http://cdn.debian.net/debian/pool/main/p/pyflakes/pyflakes_2.0.0-1.debian.tar.xz
|
||||
Patch0001: %{name}-1.1.0-python3-man.patch
|
||||
Source0: https://files.pythonhosted.org/packages/a8/0f/0dc480da9162749bf629dca76570972dd9cce5bedc60196a3c912875c87d/pyflakes-2.3.1.tar.gz
|
||||
Patch0001: 0001-Detect-typing-module-attributes-with-import-typing-a.patch
|
||||
Patch0002: 0001-remove-old-and-unused-tracing-code-625.patch
|
||||
BuildArch: noarch
|
||||
BuildRequires: python2-devel >= 2.7 python2-setuptools
|
||||
|
||||
%description
|
||||
This is a safe program which analyze programs and detects various errors.\
|
||||
It works by parsing the source file and check for error.\
|
||||
it's also much faster.
|
||||
%{common_desc}
|
||||
|
||||
%package -n python2-pyflakes
|
||||
Summary: A simple program which checks Python source files for errors
|
||||
Requires: python2-setuptools
|
||||
%{?python_provide:%python_provide python2-pyflakes}
|
||||
Provides: pyflakes = %{version}-%{release}
|
||||
Obsoletes: pyflakes < %{version}-%{release}
|
||||
|
||||
%description -n python2-pyflakes
|
||||
This is a safe program which analyze programs and detects various errors.\
|
||||
It works by parsing the source file and check for error.\
|
||||
it's also much faster.
|
||||
|
||||
%package -n python3-pyflakes
|
||||
Summary: A simple program which checks Python source files for errors
|
||||
BuildRequires: python3-devel python3-setuptools
|
||||
Requires: python3-setuptools
|
||||
%{?python_provide:%python_provide python%{python3_pkgversion}-%{name}}
|
||||
|
||||
%description -n python3-pyflakes
|
||||
This is a safe program which analyze programs and detects various errors.\
|
||||
It works by parsing the source file and check for error.\
|
||||
it's also much faster.
|
||||
%package -n python3-pyflakes
|
||||
Summary: passive checker of Python programs
|
||||
Provides: python-pyflakes
|
||||
# Base build requires
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-setuptools
|
||||
BuildRequires: python3-pbr
|
||||
BuildRequires: python3-pip
|
||||
BuildRequires: python3-wheel
|
||||
%description -n python3-pyflakes
|
||||
%{common_desc}
|
||||
|
||||
%package help
|
||||
Summary: help document and man info
|
||||
Summary: passive checker of Python programs
|
||||
Provides: python3-pyflakes-doc
|
||||
%description help
|
||||
Help document and man info for pyflakes package
|
||||
%{common_desc}
|
||||
|
||||
%prep
|
||||
%autosetup -a 1 -p1
|
||||
%autosetup -n pyflakes-2.3.1 -p1
|
||||
|
||||
%build
|
||||
%py2_build
|
||||
%py3_build
|
||||
|
||||
|
||||
%install
|
||||
|
||||
%py3_install
|
||||
mv %{buildroot}%{_bindir}/pyflakes %{buildroot}%{_bindir}/pyflakes-%{python3_version}
|
||||
ln -s pyflakes-%{python3_version} %{buildroot}%{_bindir}/pyflakes-3
|
||||
mkdir -p %{buildroot}%{_mandir}/man1
|
||||
cp debian/pyflakes3.1 %{buildroot}%{_mandir}/man1/pyflakes-%{python3_version}.1
|
||||
chmod 644 %{buildroot}%{_mandir}/man1/pyflakes-%{python3_version}.1
|
||||
touch %{buildroot}%{_mandir}/man1/pyflakes-%{python3_version}.1
|
||||
ln -s pyflakes-%{python3_version}.1 %{buildroot}%{_mandir}/man1/pyflakes-3.1
|
||||
ln -s pyflakes-3 %{buildroot}%{_bindir}/python3-pyflakes
|
||||
ln -s pyflakes-3.1 %{buildroot}%{_mandir}/man1/python3-pyflakes.1
|
||||
|
||||
%py2_install
|
||||
mv %{buildroot}%{_bindir}/pyflakes %{buildroot}%{_bindir}/pyflakes-%{python2_version}
|
||||
ln -s pyflakes-%{python2_version} %{buildroot}%{_bindir}/pyflakes-2
|
||||
mkdir -p %{buildroot}%{_mandir}/man1
|
||||
cp debian/pyflakes.1 %{buildroot}%{_mandir}/man1/pyflakes-%{python2_version}.1
|
||||
chmod 644 %{buildroot}%{_mandir}/man1/pyflakes-%{python2_version}.1
|
||||
touch %{buildroot}%{_mandir}/man1/pyflakes-%{python2_version}.1
|
||||
ln -s pyflakes-%{python2_version}.1 %{buildroot}%{_mandir}/man1/pyflakes-2.1
|
||||
ln -s pyflakes-3 %{buildroot}%{_bindir}/pyflakes
|
||||
ln -s pyflakes-3.1 %{buildroot}%{_mandir}/man1/pyflakes.1
|
||||
install -d -m755 %{buildroot}/%{_pkgdocdir}
|
||||
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
|
||||
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
|
||||
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
|
||||
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
|
||||
pushd %{buildroot}
|
||||
if [ -d usr/lib ]; then
|
||||
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
|
||||
fi
|
||||
if [ -d usr/lib64 ]; then
|
||||
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
|
||||
fi
|
||||
if [ -d usr/bin ]; then
|
||||
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
|
||||
fi
|
||||
if [ -d usr/sbin ]; then
|
||||
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
|
||||
fi
|
||||
touch doclist.lst
|
||||
if [ -d usr/share/man ]; then
|
||||
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
|
||||
fi
|
||||
popd
|
||||
mv %{buildroot}/filelist.lst .
|
||||
mv %{buildroot}/doclist.lst .
|
||||
|
||||
%check
|
||||
%{__python2} -Wall setup.py test
|
||||
%{__python3} -Wall setup.py test
|
||||
%{__python3} setup.py test
|
||||
|
||||
%files -n python2-pyflakes
|
||||
%license LICENSE
|
||||
%{_bindir}/pyflakes-2*
|
||||
%{python2_sitelib}/pyflakes*
|
||||
%exclude %{python2_sitelib}/pyflakes/test/
|
||||
%files -n python3-pyflakes -f filelist.lst
|
||||
%dir %{python3_sitelib}/*
|
||||
|
||||
%files -n python3-pyflakes
|
||||
%license LICENSE
|
||||
%{_bindir}/pyflakes-3*
|
||||
%{_bindir}/python3-pyflakes
|
||||
%{python3_sitelib}/pyflakes*
|
||||
%exclude %{python3_sitelib}/pyflakes/test/
|
||||
%{_bindir}/pyflakes
|
||||
|
||||
%files help
|
||||
%doc AUTHORS README.rst NEWS.rst
|
||||
%{_mandir}/man1/*
|
||||
|
||||
%files help -f doclist.lst
|
||||
%{_docdir}/*
|
||||
|
||||
%changelog
|
||||
* Wed Jan 31 2024 liubo <liubo1@xfusion.com> - 2.3.1-5
|
||||
- Rebuild
|
||||
|
||||
* Fri Jan 26 2024 liubo <liubo1@xfusion.com> - 2.3.1-4
|
||||
- remove old and unused "tracing" code (#625)
|
||||
|
||||
* Fri Jan 19 2024 liubo <liubo1@xfusion.com> - 2.3.1-3
|
||||
- Rebuild
|
||||
|
||||
* Tue Nov 7 2023 liubo <liubo1@xfusion.com> - 2.3.1-2
|
||||
- Detect typing module attributes with 'import typing as <name>'
|
||||
|
||||
* Mon Jul 19 2021 OpenStack_SIG <openstack@openeuler.org> - 2.3.1-1
|
||||
- update to 2.3.1
|
||||
|
||||
* Mon Nov 24 2020 zhangjiapeng <zhangjiapeng9@huawei.com> - 2.2.0-1
|
||||
- update to 2.2.0
|
||||
|
||||
* Wed Oct 21 2020 wutao <wutao61@huawei.com> - 2.1.0-2
|
||||
- delete python2 modules
|
||||
|
||||
* Tue Jun 23 2020 yanan li <liyanan032@huawei.com> - 2.1.0-1
|
||||
- Package update
|
||||
|
||||
* Fri Nov 15 2019 zhujunhao <zhujunhao5@huawei.com> - 2.0.0-8
|
||||
- package init
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
version_control: pypi
|
||||
src_repo: pyflakes
|
||||
tag_prefix: "^v"
|
||||
seperator: "."
|
||||
separator: "."
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user