From 37e85503037b384106b6b595b415fcd8a57dcc7e Mon Sep 17 00:00:00 2001 From: c0llab0rat0r <78339685+c0llab0rat0r@users.noreply.github.com> Date: Sat, 3 Apr 2021 13:32:31 -0500 Subject: [PATCH 1/5] flake8 linting corrections; ignore venv created by PyCharm --- .gitignore | 3 ++- ipfshttpclient/encoding.py | 5 +++-- ipfshttpclient/filescanner.py | 4 ++-- test/functional/test_files.py | 16 ++++++++-------- test/run-tests.py | 10 +++++----- tox.ini | 2 +- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index a03c67b5..ab84c6c6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /.project /.settings /.vscode +/venv # Stuff that never was meant to be public /+junk @@ -27,4 +28,4 @@ docs/build/ go-ipfs/ .coverage .pytest_cache/ -.tox/ \ No newline at end of file +.tox/ diff --git a/ipfshttpclient/encoding.py b/ipfshttpclient/encoding.py index d7d87f90..c0ecfa99 100644 --- a/ipfshttpclient/encoding.py +++ b/ipfshttpclient/encoding.py @@ -105,8 +105,9 @@ def __init__(self) -> None: self._decoder2 = json.JSONDecoder() self._lasterror = None # type: ty.Optional[ValueError] - @ty.no_type_check # It works just fine and I don't want to rewrite it just - # because mypy doesn't understand… # noqa: E114, E116 + # It works just fine and I don't want to rewrite it just because mypy doesn't understand… + # noqa: E114, E116 + @ty.no_type_check def parse_partial(self, data: bytes) -> ty.Generator[utils.json_value_t, ty.Any, ty.Any]: """Incrementally decodes JSON data sets into Python objects. diff --git a/ipfshttpclient/filescanner.py b/ipfshttpclient/filescanner.py index 5579a1cb..564cc352 100644 --- a/ipfshttpclient/filescanner.py +++ b/ipfshttpclient/filescanner.py @@ -512,7 +512,7 @@ def __init__( # # Note: `os.fwalk` support for binary paths was only added in 3.7+. directory_str_or_fd = directory_str # type: ty.Union[ty.AnyStr, int] - if HAVE_FWALK and (not isinstance(directory_str, bytes) or HAVE_FWALK_BYTES): # type: ignore[unreachable] # noqa: E501 + if HAVE_FWALK and (not isinstance(directory_str, bytes) or HAVE_FWALK_BYTES): # noqa: E501 self._close_fd = directory_str_or_fd = os.open(directory_str, os.O_RDONLY | O_DIRECTORY) self._generator = self._walk( @@ -583,7 +583,7 @@ def _walk( ) -> ty.Generator[FSNodeEntry, ty.Any, None]: if directory_str is not None: sep = utils.maybe_fsencode(os.path.sep, directory_str) - elif matcher is not None and matcher.is_binary: # type: ignore[unreachable] + elif matcher is not None and matcher.is_binary: sep = os.fsencode(os.path.sep) # type: ignore[assignment] else: sep = os.path.sep # type: ignore[assignment] diff --git a/test/functional/test_files.py b/test/functional/test_files.py index e041c12d..9b7b4d5e 100644 --- a/test/functional/test_files.py +++ b/test/functional/test_files.py @@ -371,17 +371,17 @@ def test_add_recursive(client, cleanup_pins): def test_add_cid_version_0(client, cleanup_pins): - with tempfile.TemporaryDirectory() as empty_dir: - response = client.add(empty_dir, cid_version=0) - assert len(response) == 1 - assert response[0]["Hash"] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" + with tempfile.TemporaryDirectory() as empty_dir: + response = client.add(empty_dir, cid_version=0) + assert len(response) == 1 + assert response[0]["Hash"] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" def test_add_cid_version_1(client, cleanup_pins): - with tempfile.TemporaryDirectory() as empty_dir: - response = client.add(empty_dir, cid_version=1) - assert len(response) == 1 - assert response[0]["Hash"] == "bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354" + with tempfile.TemporaryDirectory() as empty_dir: + response = client.add(empty_dir, cid_version=1) + assert len(response) == 1 + assert response[0]["Hash"] == "bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354" @pytest.mark.dependency(depends=["test_add_recursive"]) diff --git a/test/run-tests.py b/test/run-tests.py index 16f3dcf9..a7e18485 100755 --- a/test/run-tests.py +++ b/test/run-tests.py @@ -177,11 +177,11 @@ def pytest_pyfunc_call(self, pyfuncitem): "[run]", "omit =", ), map(lambda s: "\t" + s, omitted_files), - ( - "[report]", - "# Exclude lines specific to some other Python version from coverage", - "exclude_lines =", - ), map(lambda s: "\t" + s, exclusions)))) + ( + "[report]", + "# Exclude lines specific to some other Python version from coverage", + "exclude_lines =", + ), map(lambda s: "\t" + s, exclusions)))) coveragerc.file.flush() coverage_args = [ diff --git a/tox.ini b/tox.ini index 6089ea85..90131d9a 100644 --- a/tox.ini +++ b/tox.ini @@ -95,7 +95,7 @@ commands = [flake8] -exclude = .git,.tox,+junk,coverage,dist,doc,*egg,build,tools,test/unit,docs,*__init__.py +exclude = .git,.tox,+junk,coverage,dist,doc,*egg,build,tools,test/unit,docs,*__init__.py,venv # E221: Multiple spaces before operator # E241: Multiple spaces after ',': Breaks element alignment collections From 06278d118d39e0a14c98ef2b48b29780b24928c2 Mon Sep 17 00:00:00 2001 From: c0llab0rat0r <78339685+c0llab0rat0r@users.noreply.github.com> Date: Sat, 3 Apr 2021 13:35:11 -0500 Subject: [PATCH 2/5] Remove comment from http core dependency --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 90131d9a..2146c598 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,7 @@ deps = [testenv:py3-httpx] deps-exclusive = httpx (~= 0.14.0) - httpcore (~= 0.10.2) # Has Unix domain socket support + httpcore (~= 0.10.2) deps = {[testenv]deps} {[testenv:py3-httpx]deps-exclusive} From 5e696b7d5e2e5bbc18831415fb1109f220ddedfc Mon Sep 17 00:00:00 2001 From: c0llab0rat0r <78339685+c0llab0rat0r@users.noreply.github.com> Date: Sun, 4 Apr 2021 13:27:44 -0500 Subject: [PATCH 3/5] Remove unnecessary noqa hints related to line length --- ipfshttpclient/encoding.py | 1 - ipfshttpclient/filescanner.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ipfshttpclient/encoding.py b/ipfshttpclient/encoding.py index c0ecfa99..d660c857 100644 --- a/ipfshttpclient/encoding.py +++ b/ipfshttpclient/encoding.py @@ -106,7 +106,6 @@ def __init__(self) -> None: self._lasterror = None # type: ty.Optional[ValueError] # It works just fine and I don't want to rewrite it just because mypy doesn't understand… - # noqa: E114, E116 @ty.no_type_check def parse_partial(self, data: bytes) -> ty.Generator[utils.json_value_t, ty.Any, ty.Any]: """Incrementally decodes JSON data sets into Python objects. diff --git a/ipfshttpclient/filescanner.py b/ipfshttpclient/filescanner.py index 564cc352..9fd132c2 100644 --- a/ipfshttpclient/filescanner.py +++ b/ipfshttpclient/filescanner.py @@ -512,7 +512,7 @@ def __init__( # # Note: `os.fwalk` support for binary paths was only added in 3.7+. directory_str_or_fd = directory_str # type: ty.Union[ty.AnyStr, int] - if HAVE_FWALK and (not isinstance(directory_str, bytes) or HAVE_FWALK_BYTES): # noqa: E501 + if HAVE_FWALK and (not isinstance(directory_str, bytes) or HAVE_FWALK_BYTES): self._close_fd = directory_str_or_fd = os.open(directory_str, os.O_RDONLY | O_DIRECTORY) self._generator = self._walk( From 527160f8eed96ab0370ccdc8dbceed1c4f5bf866 Mon Sep 17 00:00:00 2001 From: c0llab0rat0r <78339685+c0llab0rat0r@users.noreply.github.com> Date: Sun, 4 Apr 2021 13:28:12 -0500 Subject: [PATCH 4/5] Correct spelling of compatibility --- test/run-tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run-tests.py b/test/run-tests.py index a7e18485..f1543e45 100755 --- a/test/run-tests.py +++ b/test/run-tests.py @@ -158,7 +158,7 @@ def pytest_pyfunc_call(self, pyfuncitem): else: # Exclude the past exclusions.append(r"\#PY2") - # Exclude code only used for compatiblity with a previous Python version + # Exclude code only used for compatibility with a previous Python version exclusions.append(r"\#PY3({0})([^\d+]|$)".format( "|".join(map(str, range(0, sys.version_info.minor))) )) From 01cdd8817d1307641419e1ca5fcd35ed026a9352 Mon Sep 17 00:00:00 2001 From: c0llab0rat0r <78339685+c0llab0rat0r@users.noreply.github.com> Date: Sun, 4 Apr 2021 13:38:34 -0500 Subject: [PATCH 5/5] Reformat coveragerc.file.writelines in run-tests.py --- test/run-tests.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/test/run-tests.py b/test/run-tests.py index f1543e45..5a3b9cee 100755 --- a/test/run-tests.py +++ b/test/run-tests.py @@ -173,15 +173,21 @@ def pytest_pyfunc_call(self, pyfuncitem): exclusions.append(r"\# pragma: http-backend=httpx") # Create temporary file with extended *coverage.py* configuration data - coveragerc.file.writelines(map(lambda s: s + "\n", itertools.chain(( - "[run]", - "omit =", - ), map(lambda s: "\t" + s, omitted_files), - ( - "[report]", - "# Exclude lines specific to some other Python version from coverage", - "exclude_lines =", - ), map(lambda s: "\t" + s, exclusions)))) + coveragerc.file.writelines( + map( + lambda s: s + "\n", + itertools.chain( + ( + "[run]", + "omit =", + ), + map(lambda s: "\t" + s, omitted_files), + ( + "[report]", + "# Exclude lines specific to some other Python version from coverage", + "exclude_lines =", + ), + map(lambda s: "\t" + s, exclusions)))) coveragerc.file.flush() coverage_args = [