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

Enforce 100% coverage #159

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
- name: Install dependencies
run: uv sync --python ${{ matrix.python-version }} --frozen

- name: Run tests
run: scripts/test

- name: Run linters
run: scripts/lint

- name: Run tests
run: scripts/test

# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
Expand Down
2 changes: 1 addition & 1 deletion multipart/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def finalize(self) -> None:
call it.
"""
# If we have a cache, write and then remove it.
if len(self.cache) > 0:
if len(self.cache) > 0: # pragma: no cover
self.underlying.write(binascii.a2b_qp(self.cache))
self.cache = b""

Expand Down
12 changes: 2 additions & 10 deletions multipart/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ class MultipartState(IntEnum):
# fmt: on


def ord_char(c: int) -> int:
return c
Comment on lines -145 to -146
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is also unreachable.



def parse_options_header(value: str | bytes) -> tuple[bytes, dict[bytes, bytes]]:
"""Parses a Content-Type header into a value in the following format: (content_type, {parameters})."""
# Uses email.message.Message to parse the header as described in PEP 594.
Expand Down Expand Up @@ -473,7 +469,7 @@ def _get_disk_file(self) -> io.BufferedRandom | tempfile._TemporaryFileWrapper[b
elif isinstance(file_dir, bytes):
dir = file_dir.decode(sys.getfilesystemencoding())
else:
dir = file_dir
dir = file_dir # pragma: no cover

# Create a temporary (named) file with the appropriate settings.
self.logger.info(
Expand Down Expand Up @@ -511,11 +507,7 @@ def on_data(self, data: bytes) -> int:
Returns:
The number of bytes written.
"""
pos = self._fileobj.tell()
bwritten = self._fileobj.write(data)
# true file objects write returns None
if bwritten is None:
bwritten = self._fileobj.tell() - pos
Comment on lines -516 to -518
Copy link
Owner Author

Choose a reason for hiding this comment

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

This code is unreachable.


# If the bytes written isn't the same as the length, just return.
if bwritten != len(data):
Expand Down Expand Up @@ -1381,7 +1373,7 @@ def data_callback(name: str, end_i: int, remaining: bool = False) -> None:
elif state == MultipartState.END:
# Do nothing and just consume a byte in the end state.
if c not in (CR, LF):
self.logger.warning("Consuming a byte '0x%x' in the end state", c)
self.logger.warning("Consuming a byte '0x%x' in the end state", c) # pragma: no cover

else: # pragma: no cover (error case)
# We got into a strange state somehow! Just stop processing.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ branch = false
omit = ["tests/*"]

[tool.coverage.report]
# fail_under = 100
fail_under = 100
skip_covered = true
show_missing = true
exclude_lines = [
Expand Down