From 36b6d2edafdc9faedb51e3c69e072cea2d26e6bb Mon Sep 17 00:00:00 2001 From: uburuntu Date: Mon, 25 May 2020 18:57:26 +0300 Subject: [PATCH 01/12] enh: remove outdated travis workaround for 3.7 --- .travis.yml | 12 ++++-------- setup.py | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 16246cb8..d28236e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,21 +3,17 @@ python: - "2.7" - "3.4" - "3.5" - - "3.6" -# Workaround for testing Python 3.7: -# https://github.com/travis-ci/travis-ci/issues/9815 -matrix: - include: - - python: 3.7 - dist: xenial - sudo: yes + - "3.7" + before_install: - pip install --upgrade setuptools pip - pip install --upgrade pylint pytest pytest-pylint pytest-runner + install: - pip install termcolor - pip install hypothesis python-Levenshtein - python setup.py develop + script: - python -m pytest # Run the tests without IPython. - pip install ipython diff --git a/setup.py b/setup.py index 0047fa95..efd3f766 100644 --- a/setup.py +++ b/setup.py @@ -70,6 +70,7 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Operating System :: OS Independent', 'Operating System :: POSIX', From 910a92ae1e006150f3008300e0e25dedd00ecfe8 Mon Sep 17 00:00:00 2001 From: uburuntu Date: Mon, 25 May 2020 18:58:22 +0300 Subject: [PATCH 02/12] new: add python 3.8 to travis.yml --- .travis.yml | 1 + setup.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d28236e4..c28a5f45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ python: - "3.4" - "3.5" - "3.7" + - "3.8" before_install: - pip install --upgrade setuptools pip diff --git a/setup.py b/setup.py index efd3f766..0047fa95 100644 --- a/setup.py +++ b/setup.py @@ -70,7 +70,6 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', 'Operating System :: OS Independent', 'Operating System :: POSIX', From 72fdf8e693c7a0ee3354a615b75d9a1830737187 Mon Sep 17 00:00:00 2001 From: uburuntu Date: Mon, 25 May 2020 18:59:17 +0300 Subject: [PATCH 03/12] new: add python 3.8 to setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 0047fa95..efd3f766 100644 --- a/setup.py +++ b/setup.py @@ -70,6 +70,7 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Operating System :: OS Independent', 'Operating System :: POSIX', From 18856f1cde0cc7369473886739dfbfd7550f916d Mon Sep 17 00:00:00 2001 From: uburuntu Date: Tue, 26 May 2020 13:38:48 +0300 Subject: [PATCH 04/12] new: add travis builds badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1482d56d..f5b2ad43 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Python Fire [![PyPI](https://img.shields.io/pypi/pyversions/fire.svg?style=plastic)](https://github.com/google/python-fire) +# Python Fire [![PyPI](https://img.shields.io/pypi/pyversions/fire.svg?style=plastic)](https://github.com/google/python-fire) [![Build Status](https://travis-ci.org/google/python-fire.svg?branch=master)](https://travis-ci.org/google/python-fire) _Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object._ From 6e22bf9ab00837561fd8a15225787af41e7f794b Mon Sep 17 00:00:00 2001 From: uburuntu Date: Tue, 26 May 2020 15:09:21 +0300 Subject: [PATCH 05/12] fix: backward compatibility for namedtuples --- fire/completion.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fire/completion.py b/fire/completion.py index 451e2021..aae9e911 100644 --- a/fire/completion.py +++ b/fire/completion.py @@ -21,6 +21,7 @@ import collections import copy import inspect +import sys from fire import inspectutils import six @@ -320,10 +321,14 @@ def MemberVisible(component, name, member, class_attrs=None, verbose=False): if class_attrs is None: class_attrs = inspectutils.GetClassAttrsDict(class_attrs) or {} class_attr = class_attrs.get(name) - if class_attr and class_attr.kind in ('method', 'property'): - # methods and properties should be accessed on instantiated objects, - # not uninstantiated classes. - return False + if class_attr: + if class_attr.kind in ('method', 'property'): + # methods and properties should be accessed on instantiated objects, + # not uninstantiated classes. + return False + if sys.version_info >= (3, 8) and isinstance(class_attr.object, collections._tuplegetter): + # backward compatibility: namedtuple elements was properties + return False if (six.PY2 and inspect.isfunction(component) and name in ('func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name')): From 7919d592a6eabc20a7f7be3843ade9f12b1563e7 Mon Sep 17 00:00:00 2001 From: uburuntu Date: Tue, 26 May 2020 15:57:18 +0300 Subject: [PATCH 06/12] fix: change condition for passing pytype --- fire/completion.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fire/completion.py b/fire/completion.py index aae9e911..95fe5be6 100644 --- a/fire/completion.py +++ b/fire/completion.py @@ -21,7 +21,6 @@ import collections import copy import inspect -import sys from fire import inspectutils import six @@ -326,8 +325,9 @@ def MemberVisible(component, name, member, class_attrs=None, verbose=False): # methods and properties should be accessed on instantiated objects, # not uninstantiated classes. return False - if sys.version_info >= (3, 8) and isinstance(class_attr.object, collections._tuplegetter): - # backward compatibility: namedtuple elements was properties + tuplegetter = getattr(collections, '_tuplegetter', None) + if tuplegetter and isinstance(class_attr.object, type(tuplegetter)): + # backward compatibility: namedtuple attributes were properties return False if (six.PY2 and inspect.isfunction(component) and name in ('func_closure', 'func_code', 'func_defaults', From 8f8b25bf32dd80f8964a01e6df4d2fd6c87a3006 Mon Sep 17 00:00:00 2001 From: uburuntu Date: Tue, 26 May 2020 17:32:10 +0300 Subject: [PATCH 07/12] fix: delete wrong type() --- fire/completion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fire/completion.py b/fire/completion.py index 95fe5be6..8669b58d 100644 --- a/fire/completion.py +++ b/fire/completion.py @@ -326,7 +326,7 @@ def MemberVisible(component, name, member, class_attrs=None, verbose=False): # not uninstantiated classes. return False tuplegetter = getattr(collections, '_tuplegetter', None) - if tuplegetter and isinstance(class_attr.object, type(tuplegetter)): + if tuplegetter is not None and isinstance(class_attr.object, tuplegetter): # backward compatibility: namedtuple attributes were properties return False if (six.PY2 and inspect.isfunction(component) From 8915c460c5953bec6dcadab99555bd5b289542de Mon Sep 17 00:00:00 2001 From: uburuntu Date: Tue, 26 May 2020 17:40:55 +0300 Subject: [PATCH 08/12] fix: try to bypass pylint `isinstance-second-argument-not-valid-type` --- fire/completion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fire/completion.py b/fire/completion.py index 8669b58d..14f116a4 100644 --- a/fire/completion.py +++ b/fire/completion.py @@ -325,7 +325,7 @@ def MemberVisible(component, name, member, class_attrs=None, verbose=False): # methods and properties should be accessed on instantiated objects, # not uninstantiated classes. return False - tuplegetter = getattr(collections, '_tuplegetter', None) + tuplegetter = getattr(collections, '_tuplegetter', type(None)) if tuplegetter is not None and isinstance(class_attr.object, tuplegetter): # backward compatibility: namedtuple attributes were properties return False From 352f55889f3da291e3be5d98fe97c72bf961208e Mon Sep 17 00:00:00 2001 From: uburuntu Date: Tue, 26 May 2020 17:48:10 +0300 Subject: [PATCH 09/12] fix: finally enhance code style --- fire/completion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fire/completion.py b/fire/completion.py index 14f116a4..5c5ad490 100644 --- a/fire/completion.py +++ b/fire/completion.py @@ -326,7 +326,7 @@ def MemberVisible(component, name, member, class_attrs=None, verbose=False): # not uninstantiated classes. return False tuplegetter = getattr(collections, '_tuplegetter', type(None)) - if tuplegetter is not None and isinstance(class_attr.object, tuplegetter): + if isinstance(class_attr.object, tuplegetter): # backward compatibility: namedtuple attributes were properties return False if (six.PY2 and inspect.isfunction(component) From ef2d7a93c4d71e4f32dd8d82d580b0cc2d5f2f2a Mon Sep 17 00:00:00 2001 From: uburuntu Date: Tue, 26 May 2020 18:42:14 +0300 Subject: [PATCH 10/12] fix: skip pytype for 3.8 --- .travis.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c28a5f45..a83a2a90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ before_install: - pip install --upgrade pylint pytest pytest-pylint pytest-runner install: - - pip install termcolor - - pip install hypothesis python-Levenshtein + - pip install termcolor hypothesis python-Levenshtein + - if [[ $TRAVIS_PYTHON_VERSION != 3.4 ]]; then pip install pytype; fi - python setup.py develop script: @@ -20,15 +20,12 @@ script: - pip install ipython - python -m pytest # Now run the tests with IPython. - pylint fire --ignore=test_components_py3.py,parser_fuzz_test.py,console - - if [[ $TRAVIS_PYTHON_VERSION != 3.4 ]]; then - pip install pytype; - fi # Run type-checking, excluding files that define or use py3 features in py2. - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pytype -x fire/fire_test.py fire/inspectutils_test.py fire/test_components_py3.py; - elif [[ $TRAVIS_PYTHON_VERSION != 3.4 ]]; then - pytype; fi + # Waiting for Python 3.8 support: https://github.com/google/pytype/pull/587 + - if [[ $TRAVIS_PYTHON_VERSION == 3.* && $TRAVIS_PYTHON_VERSION != 3.[48] ]]; then pytype; fi From 9e93d6cc80a7e474842c8adf04f33808f373c253 Mon Sep 17 00:00:00 2001 From: uburuntu Date: Thu, 4 Jun 2020 16:24:07 +0300 Subject: [PATCH 11/12] new: travis with pytype on 3.8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a83a2a90..98e239ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,4 +28,4 @@ script: fire/test_components_py3.py; fi # Waiting for Python 3.8 support: https://github.com/google/pytype/pull/587 - - if [[ $TRAVIS_PYTHON_VERSION == 3.* && $TRAVIS_PYTHON_VERSION != 3.[48] ]]; then pytype; fi + - if [[ $TRAVIS_PYTHON_VERSION == 3.* && $TRAVIS_PYTHON_VERSION != 3.4 ]]; then pytype; fi From efaf65fe5b0986121f0e1b76a949a07169dd354f Mon Sep 17 00:00:00 2001 From: uburuntu Date: Thu, 4 Jun 2020 16:28:18 +0300 Subject: [PATCH 12/12] del: remove outdated comment --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98e239ef..3f44d69c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,5 +27,4 @@ script: fire/inspectutils_test.py fire/test_components_py3.py; fi - # Waiting for Python 3.8 support: https://github.com/google/pytype/pull/587 - if [[ $TRAVIS_PYTHON_VERSION == 3.* && $TRAVIS_PYTHON_VERSION != 3.4 ]]; then pytype; fi