Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Feb 29, 2024
1 parent 34abbac commit 7134a56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
13 changes: 8 additions & 5 deletions bibtexparser/middlewares/fieldkeys.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import logging
from typing import Dict, List, Set
from typing import Dict
from typing import List
from typing import Set

from bibtexparser.library import Library
from bibtexparser.model import Entry, Field
from bibtexparser.model import Entry
from bibtexparser.model import Field

from .middleware import BlockMiddleware

Expand Down Expand Up @@ -35,9 +38,9 @@ def transform_entry(self, entry: Entry, library: "Library") -> Entry:
# to remove "seen_normalized_keys" and this if statement
if normalized_key in seen_normalized_keys:
logging.warning(
f"NormalizeFieldKeys: in entry '{entry.key}': " +
f"duplicate normalized key '{normalized_key}' " +
f"(original '{field.key}'); overriding previous value"
f"NormalizeFieldKeys: in entry '{entry.key}': "
+ f"duplicate normalized key '{normalized_key}' "
+ f"(original '{field.key}'); overriding previous value"
)
seen_normalized_keys.add(normalized_key)
field.key = normalized_key
Expand Down
9 changes: 3 additions & 6 deletions tests/middleware_tests/test_fieldkeys.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import re

import pytest

from bibtexparser import Library
from bibtexparser.middlewares.fieldkeys import NormalizeFieldKeys
from bibtexparser.model import Entry, Field
from bibtexparser.model import Entry
from bibtexparser.model import Field

entries = {
"article": {
Expand Down Expand Up @@ -63,9 +62,7 @@ def test_normalize_fieldkeys_force_last(caplog):
lib.add(Entry(entry_type=entry_type, key=f"entry{i}", fields=f))

lib = NormalizeFieldKeys().transform(lib)
assert re.match(
r"(WARNING\s*)(\w*\:\w*\.py\:[0-9]*\s*)(NormalizeFieldKeys)(.*)", caplog.text
)
assert re.match(r"(WARNING\s*)(\w*\:\w*\.py\:[0-9]*\s*)(NormalizeFieldKeys)(.*)", caplog.text)

for key in lib.entries_dict:
assert lib.entries_dict[key] == ref.entries_dict[key]

0 comments on commit 7134a56

Please sign in to comment.