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

chore: update pre-commit pins and fix issues #836

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.11.2
hooks:
- id: mypy
exclude: '^(docs|tasks|tests)|setup\.py'
args: []
additional_dependencies: [pyparsing, nox]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.6.8
hooks:
- id: ruff
args: [ --fix ]
args: [ --fix, --show-fixes ]
- id: ruff-format
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ module = ["_manylinux"]
ignore_missing_imports = true


[tool.ruff]
src = ["src"]

[tool.ruff.lint]
extend-select = [
"B",
Expand Down
14 changes: 7 additions & 7 deletions src/packaging/metadata.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

import builtins
import email.feedparser
import email.header
import email.message
import email.parser
import email.policy
import sys
import typing
from typing import (
Any,
Expand All @@ -22,9 +22,7 @@
T = typing.TypeVar("T")


if "ExceptionGroup" in builtins.__dict__: # pragma: no cover
ExceptionGroup = ExceptionGroup
else: # pragma: no cover
if sys.version_info < (3, 11): # pragma: no cover

class ExceptionGroup(Exception):
"""A minimal implementation of :external:exc:`ExceptionGroup` from Python 3.11.
Expand All @@ -42,6 +40,8 @@ def __init__(self, message: str, exceptions: list[Exception]) -> None:

def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.message!r}, {self.exceptions!r})"
else: # pragma: no cover
from builtins import ExceptionGroup


class InvalidMetadata(ValueError):
Expand Down Expand Up @@ -214,12 +214,12 @@ def _get_payload(msg: email.message.Message, source: bytes | str) -> str:
# If our source is a str, then our caller has managed encodings for us,
# and we don't need to deal with it.
if isinstance(source, str):
payload: str = msg.get_payload()
payload: str = msg.get_payload() # type: ignore[assignment]
return payload
# If our source is a bytes, then we're managing the encoding and we need
# to deal with it.
else:
bpayload: bytes = msg.get_payload(decode=True)
bpayload: bytes = msg.get_payload(decode=True) # type: ignore[assignment]
try:
return bpayload.decode("utf8", "strict")
except UnicodeDecodeError as exc:
Expand Down Expand Up @@ -424,7 +424,7 @@ def parse_email(data: bytes | str) -> tuple[RawMetadata, dict[str, list[str]]]:
payload = _get_payload(parsed, data)
except ValueError:
unparsed.setdefault("description", []).append(
parsed.get_payload(decode=isinstance(data, bytes))
parsed.get_payload(decode=isinstance(data, bytes)) # type: ignore[call-overload]
)
else:
if payload:
Expand Down
Loading