From 7b29fc3f65e4254394801edb538473767d6e0875 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Fri, 12 Jun 2026 13:13:54 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Fix=20type=20annotation?= =?UTF-8?q?s=20on=20public=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- bibtexparser/entrypoint.py | 5 +++-- bibtexparser/middlewares/latex_encoding.py | 8 ++++---- bibtexparser/middlewares/names.py | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bibtexparser/entrypoint.py b/bibtexparser/entrypoint.py index e654c60..d55ce81 100644 --- a/bibtexparser/entrypoint.py +++ b/bibtexparser/entrypoint.py @@ -4,6 +4,7 @@ from typing import List from typing import Optional from typing import TextIO +from typing import Tuple from typing import Union from .library import Library @@ -80,7 +81,7 @@ def _handle_deprecated_write_params( prepend_middleware: Optional[Iterable[Middleware]], kwargs: dict, function_name: str, -) -> tuple[Optional[Iterable[Middleware]], Optional[Iterable[Middleware]]]: +) -> Tuple[Optional[Iterable[Middleware]], Optional[Iterable[Middleware]]]: """Handle deprecated parameter names for write functions. :param unparse_stack: Current unparse_stack value @@ -126,7 +127,7 @@ def parse_string( parse_stack: Optional[Iterable[Middleware]] = None, append_middleware: Optional[Iterable[Middleware]] = None, library: Optional[Library] = None, -): +) -> Library: """Parse a BibTeX string. :param bibtex_str: BibTeX string to parse diff --git a/bibtexparser/middlewares/latex_encoding.py b/bibtexparser/middlewares/latex_encoding.py index 9139763..1e762ad 100644 --- a/bibtexparser/middlewares/latex_encoding.py +++ b/bibtexparser/middlewares/latex_encoding.py @@ -90,8 +90,8 @@ class LatexEncodingMiddleware(_PyStringTransformerMiddleware): def __init__( self, - keep_math: bool = None, - enclose_urls: bool = None, + keep_math: Optional[bool] = None, + enclose_urls: Optional[bool] = None, encoder: Optional[UnicodeToLatexEncoder] = None, allow_inplace_modification: bool = True, ): @@ -161,8 +161,8 @@ class LatexDecodingMiddleware(_PyStringTransformerMiddleware): def __init__( self, allow_inplace_modification: bool = True, - keep_braced_groups: bool = None, - keep_math_mode: bool = None, + keep_braced_groups: Optional[bool] = None, + keep_math_mode: Optional[bool] = None, decoder: Optional[LatexNodes2Text] = None, ): super().__init__( diff --git a/bibtexparser/middlewares/names.py b/bibtexparser/middlewares/names.py index 69b7eac..45d1eb1 100644 --- a/bibtexparser/middlewares/names.py +++ b/bibtexparser/middlewares/names.py @@ -37,7 +37,7 @@ class _NameTransformerMiddleware(BlockMiddleware, abc.ABC): def __init__( self, allow_inplace_modification: bool = True, - name_fields: Tuple[str] = ("author", "editor", "translator"), + name_fields: Tuple[str, ...] = ("author", "editor", "translator"), ): super().__init__( allow_inplace_modification=allow_inplace_modification, @@ -46,7 +46,7 @@ def __init__( self._name_fields = name_fields @property - def name_fields(self) -> Tuple[str]: + def name_fields(self) -> Tuple[str, ...]: """The fields that contain names, considered by this middleware.""" return self._name_fields @@ -187,7 +187,7 @@ def __init__( self, style: Literal["last", "first"] = "last", allow_inplace_modification: bool = True, - name_fields: Tuple[str] = ("author", "editor", "translator"), + name_fields: Tuple[str, ...] = ("author", "editor", "translator"), ): self.style = style super().__init__(allow_inplace_modification, name_fields)