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

👌 IMPROVE: Support for keeping abbreviations at enclosing values. #491

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lartpang
Copy link

@lartpang lartpang commented Oct 10, 2024

@drakeguan @jagd @mgorny @sjpfenninger

In this commit, I add a new argument keep_abbr_string into AddEnclosingMiddleware to keep the abbreviation (@string) when enclosing the value and not resolving the string.

@MiWeiss MiWeiss self-requested a review October 20, 2024 18:50
)
@pytest.mark.parametrize("inplace", [True, False], ids=["inplace", "not_inplace"])
def test_addition_of_enclosing_on_entry_with_abbr(
value: tuple,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
value: tuple,
value: tuple[str,bool],

@MiWeiss
Copy link
Collaborator

MiWeiss commented Oct 20, 2024

Hi @lartpang

Thanks a lot for your PR.

This is certainly a feature we want to support. However, there's two major comments to address:

  • In principle, I try to keep a match between "Parse" and "Write" Middleware, where the latter (partially) reverts the first. In your case: The stings were dereferenced in ResolveStringReferencesMiddleware, thus they should be put back in a ResolveStringReferencesMiddleware (in interpolate.py). I see how that's not very straight forward (as its very connected to the enclosings) - but please try to consider moving your solution in that direction. Then, if you absolutely can't find a nice solution, just say so. I'll have a look and re-evaluate (I'm a bit short on time atm).
  • Make sure the test suite covers end-to-end cases, i.e., cases where the ResolveStringReferencesMiddleware works together with your middleware changes. That's important to protect from regressions, as the two are very much tied together.

I'll check for minor things after we settled on these, but I don't expect any hickups after that :-)

Thanks again

@lartpang
Copy link
Author

@MiWeiss Thanks for your review.

In principle, I try to keep a match between "Parse" and "Write" Middleware, where the latter (partially) reverts the first. In your case: The strings were dereferenced in ResolveStringReferencesMiddleware, thus they should be put back in a ResolveStringReferencesMiddleware (in interpolate.py). I see how that's not very straight forward (as its very connected to the enclosings) - but please try to consider moving your solution in that direction. Then, if you absolutely can't find a nice solution, just say so. I'll have a look and re-evaluate (I'm a bit short on time atm).

ResolveStringReferencesMiddleware is used to resolve string objects in bibtex, which seems to conflict with the feature of retaining string objects in this commit:
Because if ResolveStringReferencesMiddleware is used, it explicitly indicates that string objects should be resolved, so there would be no need to emphasize "retaining string objects" additionally.
The requirement to "retain string objects" only exists when enclosing values (maybe), which seems difficult to decouple from the operation of AddEnclosingMiddleware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants