-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 trailing commas in macro signatures, calls & with statements #1712
Open
Zocker1999NET
wants to merge
9
commits into
pallets:main
Choose a base branch
from
Zocker1999NET:trailing-comma
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
was missing for: - parse_list - parse_dict
- to test already added support for trailing commas in macro arguments Original source: njl@7b2f718
- to test already supported trailing comma on macro call arguments
Original source: njl@7b2f718
- to test newly supported trailing commas in macro signatures Original source: njl@7b2f718
- to test support for trailing commas in with statements
Zocker1999NET
force-pushed
the
trailing-comma
branch
from
August 28, 2022 14:52
c1d7ead
to
7d1c34e
Compare
for both support for trailing commas for - macro signatures - with statements
Zocker1999NET
added a commit
to Zocker1999NET/jinja
that referenced
this pull request
Nov 6, 2022
Zocker1999NET
added a commit
to Zocker1999NET/jinja
that referenced
this pull request
Nov 6, 2022
for both support for trailing commas for - macro signatures - with statements
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change improves support for trailing commas on macros & with statements by adding tests for already supported trailing commas and adding support & tests for "new" trailing commas.
The support for trailing commas is implemented as follows: By checking at the beginning of a loop but after parsing a comma if the current statement is already closed and ignoring/accepting this, trailing commas become supported. This technique is already used by other parsers in Jinja (e.g. for list & dictionaries). It was copied from other implementations already comitted here and from @njl's implemention from #107, which was probably not merged due to the misunderstanding that #100 was already fixed.
I took the freedom to add support for trailing commas in with statements here as well without creating a concrete issue before. I hope that's okay, otherwise I'm willing to open an issue if one is required. I can also split this change from this PR if that is required.
I also commented the code which adds support for trailing spaces for lists & dictionaries so these are explained like other similar code already is.
Checklist:
CHANGES.rst
summarizing the change and linking to the issue... versionchanged::
entries in any relevant code docs.pre-commit
hooks and fix any issues.pytest
andtox
, no tests failed.