Skip to content

Commit

Permalink
fix Literal import
Browse files Browse the repository at this point in the history
  • Loading branch information
mlutze committed Nov 28, 2023
1 parent ce0fb2f commit eef5dd4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bibtexparser/middlewares/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
"""
import abc
import dataclasses
from typing import List, Literal, Tuple
from typing import List, Tuple

# Literal is only available in Python 3.8+
try:
from typing import Literal
FirstOrLastType = Literal["first", "last"]
except ImportError:
FirstOrLastType = str

from bibtexparser.model import Block, Entry, Field, MiddlewareErrorBlock

Expand Down Expand Up @@ -179,7 +186,7 @@ class MergeNameParts(_NameTransformerMiddleware):

def __init__(
self,
style: Literal["last"] | Literal["first"] = "last",
style: FirstOrLastType = "last",
allow_inplace_modification: bool = True,
name_fields: Tuple[str] = ("author", "editor", "translator"),
):
Expand Down

0 comments on commit eef5dd4

Please sign in to comment.