From 5324ae48c8a2e9fa6dfed77caf90994a8afc2804 Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 10:53:37 -0400 Subject: [PATCH 01/11] Add black linting --- .travis.yml | 1 + Makefile | 3 +++ README.md | 2 +- codecov/__init__.py | 35 +++++++++++++++++++++-------------- codecov/__version__.py | 17 ++++++++--------- setup.py | 16 ++++++++-------- tests/requirements.txt | 1 + tests/test.py | 5 ++++- 8 files changed, 47 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28c4c162..8ed48c93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ install: - python setup.py install script: - make reinstall + - make lint - make test # - pytest tests/test.py --cov=codecov after_success: diff --git a/Makefile b/Makefile index cd09f059..50c2789c 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,9 @@ reinstall: test: py.test tests/test.py +lint: + black . + compare: hub compare $(shell git tag --sort=refname | tail -1)...master diff --git a/README.md b/README.md index 0959d646..17cbc3b4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Codecov Global Python Uploader [![codecov.io](https://codecov.io/github/codecov/codecov-python/coverage.svg?branch=master)](https://codecov.io/github/codecov/codecov-python) +Codecov Global Python Uploader [![codecov.io](https://codecov.io/github/codecov/codecov-python/coverage.svg?branch=master)](https://codecov.io/github/codecov/codecov-python) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) ======= | [https://codecov.io/][1] | [@codecov][2] | [hello@codecov.io][3] | | ------------------------ | ------------- | --------------------- | diff --git a/codecov/__init__.py b/codecov/__init__.py index 42e38aa6..2ac36114 100644 --- a/codecov/__init__.py +++ b/codecov/__init__.py @@ -40,7 +40,7 @@ logging.captureWarnings(True) -version=__version__ +version = __version__ COLOR = True @@ -902,17 +902,24 @@ def main(*argv, **kwargs): write("XX> Skip processing gcov") else: - dont_search_here = [ - "bower_components" - "node_modules" - "vendor" - ] + dont_search_here = ["bower_components" "node_modules" "vendor"] if codecov.gcov_glob: dont_search_here.append(codecov.gcov_glob) write("==> Processing gcov (disable by -X gcov)") - for path in find_files(sanitize_arg("", codecov.gcov_root or root), "*.gcno", True, dont_search_here): - cmd = sanitize_arg("", codecov.gcov_exec or "") + " -pb " + sanitize_arg("", codecov.gcov_args or "") + " " + path + for path in find_files( + sanitize_arg("", codecov.gcov_root or root), + "*.gcno", + True, + dont_search_here, + ): + cmd = ( + sanitize_arg("", codecov.gcov_exec or "") + + " -pb " + + sanitize_arg("", codecov.gcov_args or "") + + " " + + path + ) write(" Executing gcov (%s)" % cmd) write(try_to_run(cmd)) @@ -1056,8 +1063,8 @@ def main(*argv, **kwargs): headers={ "Accept": "text/plain", "X-Reduced-Redundancy": "false", - "X-Content-Type": "application/x-gzip" - } + "X-Content-Type": "application/x-gzip", + }, ) if res.status_code in (400, 406): raise Exception(res.text) @@ -1073,8 +1080,8 @@ def main(*argv, **kwargs): data=reports_gzip, headers={ "Content-Type": "application/x-gzip", - "Content-Encoding": "gzip" - } + "Content-Encoding": "gzip", + }, ) s3.raise_for_status() assert s3.status_code == 200 @@ -1096,8 +1103,8 @@ def main(*argv, **kwargs): headers={ "Accept": "text/plain", "Content-Type": "application/x-gzip", - "Content-Encoding": "gzip" - } + "Content-Encoding": "gzip", + }, ) if res.status_code < 500: write(" " + res.text) diff --git a/codecov/__version__.py b/codecov/__version__.py index f33db7ec..3955eb75 100644 --- a/codecov/__version__.py +++ b/codecov/__version__.py @@ -1,9 +1,8 @@ -__author__ = 'Codecov' -__author_email__ = 'support@codecov.io' -__copyright__ = 'Copyright 2020 Codecov' -__description__ = 'Hosted coverage reports for GitHub, Bitbucket and Gitlab' -__license__ = 'Apache 2.0' -__title__ = 'codecov' -__url__ = 'https://github.com/codecov/codecov-python' -__version__ = '2.1.3' - +__author__ = "Codecov" +__author_email__ = "support@codecov.io" +__copyright__ = "Copyright 2020 Codecov" +__description__ = "Hosted coverage reports for GitHub, Bitbucket and Gitlab" +__license__ = "Apache 2.0" +__title__ = "codecov" +__url__ = "https://github.com/codecov/codecov-python" +__version__ = "2.1.3" diff --git a/setup.py b/setup.py index 1e8f0dc3..4d418234 100644 --- a/setup.py +++ b/setup.py @@ -23,20 +23,20 @@ filepath = os.path.abspath(os.path.dirname(__file__)) about = {} -with open(os.path.join(filepath, 'codecov', '__version__.py'), 'r', 'utf-8') as f: +with open(os.path.join(filepath, "codecov", "__version__.py"), "r", "utf-8") as f: exec(f.read(), about) setup( - name=about['__title__'], - version=about['__version__'], - description=about['__description__'], + name=about["__title__"], + version=about["__version__"], + description=about["__description__"], long_description=None, classifiers=classifiers, keywords="coverage codecov code python java scala php", - author=about['__author__'], - author_email=about['__author_email__'], - url=about['__url__'], - license=about['__license__'], + author=about["__author__"], + author_email=about["__author_email__"], + url=about["__url__"], + license=about["__license__"], packages=["codecov"], include_package_data=True, zip_safe=True, diff --git a/tests/requirements.txt b/tests/requirements.txt index 62de37c5..36ad7f1c 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -5,3 +5,4 @@ pytest>=3.6.0 pytest-cov funcsigs requests +black diff --git a/tests/test.py b/tests/test.py index 3c396be9..279d21ec 100644 --- a/tests/test.py +++ b/tests/test.py @@ -269,7 +269,10 @@ def test_send(self): assert "token=%3Ctoken%3E" in post.call_args[0][0] assert "branch=master" in post.call_args[0][0] gzip_worker = zlib.decompressobj(zlib.MAX_WBITS | 16) - reports = gzip_worker.decompress(put.call_args[1]["data"]) + gzip_worker.flush() + reports = ( + gzip_worker.decompress(put.call_args[1]["data"]) + + gzip_worker.flush() + ) assert u"tests/test.py".encode("utf-8") in reports def test_send_error(self): From 4caf9ecc59e5d49b8479e9a42f3638dd78ebb9d0 Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 10:55:33 -0400 Subject: [PATCH 02/11] Make black a checking call --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 50c2789c..a79d4627 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ test: py.test tests/test.py lint: - black . + black . --check compare: hub compare $(shell git tag --sort=refname | tail -1)...master From 9a329b996079c9907a1749521dd34fb1affe2ec0 Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 10:56:41 -0400 Subject: [PATCH 03/11] Call it formatting --- .travis.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8ed48c93..7d096fef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ install: - python setup.py install script: - make reinstall - - make lint + - make format - make test # - pytest tests/test.py --cov=codecov after_success: diff --git a/Makefile b/Makefile index a79d4627..b166e62e 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ reinstall: test: py.test tests/test.py -lint: +format: black . --check compare: From 30444067e790ab4727df2f31be8b7526250e777f Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 11:53:08 -0400 Subject: [PATCH 04/11] Isolate black to 3.6 and 3.7 --- .travis.yml | 5 +++++ Makefile | 2 +- tests/requirements.txt | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d096fef..94859e38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,13 @@ matrix: - python-requests - python-coverage - python-mock + - python: 3.6 + before_install: + - pip install black - python: 3.7 dist: xenial + before_install: + - pip install black install: - pip install -r tests/requirements.txt diff --git a/Makefile b/Makefile index b166e62e..8b8625da 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ test: py.test tests/test.py format: - black . --check + which -s black && black . --check compare: hub compare $(shell git tag --sort=refname | tail -1)...master diff --git a/tests/requirements.txt b/tests/requirements.txt index 36ad7f1c..62de37c5 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -5,4 +5,3 @@ pytest>=3.6.0 pytest-cov funcsigs requests -black From 8c616eb81c37205d61d1d81eabe9caeada618c80 Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 11:55:11 -0400 Subject: [PATCH 05/11] do a check on requirements --- .travis.yml | 5 ----- tests/requirements.txt | 1 + tests/~ | 8 ++++++++ 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 tests/~ diff --git a/.travis.yml b/.travis.yml index 94859e38..7d096fef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,13 +24,8 @@ matrix: - python-requests - python-coverage - python-mock - - python: 3.6 - before_install: - - pip install black - python: 3.7 dist: xenial - before_install: - - pip install black install: - pip install -r tests/requirements.txt diff --git a/tests/requirements.txt b/tests/requirements.txt index 62de37c5..9b6d87dd 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -5,3 +5,4 @@ pytest>=3.6.0 pytest-cov funcsigs requests +black ; python_version >= '3.6' diff --git a/tests/~ b/tests/~ new file mode 100644 index 00000000..9b6d87dd --- /dev/null +++ b/tests/~ @@ -0,0 +1,8 @@ +coverage>=4.4.0 +ddt +mock +pytest>=3.6.0 +pytest-cov +funcsigs +requests +black ; python_version >= '3.6' From e7c339ca3b6db8acb8362a309f6e4f54289e03e7 Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 11:57:46 -0400 Subject: [PATCH 06/11] Fix readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f901788d..fe8adbd6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ Codecov Global Python Uploader ![PyPI](https://img.shields.io/pypi/v/codecov) [![codecov.io](https://codecov.io/github/codecov/codecov-python/coverage.svg?branch=master)](https://codecov.io/github/codecov/codecov-python) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) - +======= | [https://codecov.io/][1] | [@codecov][2] | [hello@codecov.io][3] | | ------------------------ | ------------- | --------------------- | From 7d705be5a30958ba9c22de141f002dc2d98e8439 Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 12:23:02 -0400 Subject: [PATCH 07/11] Remove -s argment --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8b8625da..1262230c 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ test: py.test tests/test.py format: - which -s black && black . --check + which black && black . --check compare: hub compare $(shell git tag --sort=refname | tail -1)...master From ad9e538589e6acda2378413e59087358234b2cdf Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 12:31:06 -0400 Subject: [PATCH 08/11] maybe we dont need which --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1262230c..b166e62e 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ test: py.test tests/test.py format: - which black && black . --check + black . --check compare: hub compare $(shell git tag --sort=refname | tail -1)...master From 9d43fb49590451744724752aed66bd2143b67b1c Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 12:38:34 -0400 Subject: [PATCH 09/11] Run formatting only on 3.7 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7d096fef..2e6150f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,13 +26,13 @@ matrix: - python-mock - python: 3.7 dist: xenial + script: make format install: - pip install -r tests/requirements.txt - python setup.py install script: - make reinstall - - make format - make test # - pytest tests/test.py --cov=codecov after_success: From 08b098829820e9e19900dd54b461d3c16b5e6d29 Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 12:56:01 -0400 Subject: [PATCH 10/11] Remove extra dir --- tests/~ | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 tests/~ diff --git a/tests/~ b/tests/~ deleted file mode 100644 index 9b6d87dd..00000000 --- a/tests/~ +++ /dev/null @@ -1,8 +0,0 @@ -coverage>=4.4.0 -ddt -mock -pytest>=3.6.0 -pytest-cov -funcsigs -requests -black ; python_version >= '3.6' From 098c82bf13bc68b15413eeb83337a5505a0f06fc Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Fri, 22 May 2020 13:03:52 -0400 Subject: [PATCH 11/11] Only install on 3.7 because pypy is 3.6 and uses typed-ast --- tests/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/requirements.txt b/tests/requirements.txt index 9b6d87dd..f70ccf3f 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -5,4 +5,4 @@ pytest>=3.6.0 pytest-cov funcsigs requests -black ; python_version >= '3.6' +black ; python_version >= '3.7'