python-bibtexparser icon indicating copy to clipboard operation
python-bibtexparser copied to clipboard

add NormalizeFieldKeys middleware

Open Technologicat opened this issue 1 year ago • 4 comments
trafficstars

Here's an attempt at #467, which see.

Fixes #467

Technologicat avatar Feb 19 '24 11:02 Technologicat

(Thanks BTW ;))

tdegeus avatar Feb 19 '24 13:02 tdegeus

(Thanks BTW ;))

(np BTW ;))

Technologicat avatar Feb 19 '24 13:02 Technologicat

Also, noticed that black was complaining, so reformatted both fieldkeys.py and test_fieldkeys.py using it.

Technologicat avatar Feb 23 '24 11:02 Technologicat

Thanks @Technologicat !! Since I had a few minutes to spare, I offered some simplifying suggestions by adding to commits. Please don't hesitate to criticize / complement / revert.

tdegeus avatar Feb 23 '24 13:02 tdegeus

4b328ba: Ok, nice shortened comment. Thanks. 6ad724f: Ok. 9eed680: Ok.

71ee1de: Nice shortening of the test unit. Thanks!

Regarding this commit, some minor comments:

Contrary to the docstring, the function test_normalize_fieldkeys is actually testing with lowercase keys. I think the docstring should be fixed. This is important, because as the old maxim goes, "if code and comments disagree, both are probably wrong".

Personally, I'd also avoid the name "foo{i}". A semantically meaningful name, such as "entry{i}", would increase clarity by making the intent explicit. Similarly, in test_normalize_fieldkeys_force_last, the bare "foo" could be e.g. "dummyvalue" to make it clear at a glance what it stands for.

(Using meaningful names exclusively is a habit I picked up from Racket docs ~half a decade ago. The standard metasyntactic names were fine in the 1970s, but we know better now. :) )

Technologicat avatar Feb 28 '24 12:02 Technologicat

Sounds good! Would you like to make the changes?

tdegeus avatar Feb 28 '24 12:02 tdegeus

Sure, here they are. :)

Technologicat avatar Feb 29 '24 12:02 Technologicat

Ugh, a merge conflict. Fixed. And some flake8 warnings fixed, too.

Should be fine by me now.

Technologicat avatar Feb 29 '24 12:02 Technologicat

Thanks a million!

tdegeus avatar Feb 29 '24 13:02 tdegeus

Thanks for the merge!

Technologicat avatar Feb 29 '24 13:02 Technologicat