Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix httpcore dependency; fix style linting #257

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/.project
/.settings
/.vscode
/venv

# Stuff that never was meant to be public
/+junk
Expand All @@ -27,4 +28,4 @@ docs/build/
go-ipfs/
.coverage
.pytest_cache/
.tox/
.tox/
5 changes: 3 additions & 2 deletions ipfshttpclient/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
c0llab0rat0r marked this conversation as resolved.
Show resolved Hide resolved
@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.

Expand Down
4 changes: 2 additions & 2 deletions ipfshttpclient/filescanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
c0llab0rat0r marked this conversation as resolved.
Show resolved Hide resolved
self._close_fd = directory_str_or_fd = os.open(directory_str, os.O_RDONLY | O_DIRECTORY)

self._generator = self._walk(
Expand Down Expand Up @@ -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]
Expand Down
16 changes: 8 additions & 8 deletions test/functional/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
10 changes: 5 additions & 5 deletions test/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will behave better here if you move the opening parenthese to the line above. The way it's currently written was actually a workaround to a bug in an older version of the checker. 😉

Copy link
Contributor

@ntninja ntninja Apr 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will behave better here if you move the opening parenthese to the line above. The way it's currently written was actually a workaround to a bug in an older version of the checker. wink

^ Do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had tried simply moving the parenthesis on line 180 up earlier but it didn't like that. The latest change flattens that entire section and passes the linter.

"[report]",
"# Exclude lines specific to some other Python version from coverage",
"exclude_lines =",
), map(lambda s: "\t" + s, exclusions))))
coveragerc.file.flush()

coverage_args = [
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down