-
-
Notifications
You must be signed in to change notification settings - Fork 80
Format generated Python parser module #347
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
Conversation
c50567f to
ab8bc7c
Compare
|
I’m 👎 for this change:
the reason is that you should be able to subclass AstParser and override |
- Removes configuring exclusion of any Python modules from formatting - Ensure entire library is formatted correctly - Drop redundant `or False` logic from conditionals - Drop redundant `else` conditionals after `return` within `if` clause - Skipped formatting on `state_comment` string - Challenging to generate formatted Python multiline string from C#
- Faster tooling - Better handling with linting rule conflicts - Enables extending to hundreds of linting rules - Aligns with pytest-bdd (pytest-dev/pytest-bdd#758)
ab8bc7c to
52864a5
Compare
Makes sense - applied! Had been unsure on the same for a somewhat related reason - being too implicit by assessing "truthiness" rather than the explicit type declarations - which could become a consideration with changes down the line should users begin passing additional values. Accustomed to using in a local context without this consideration. Interesting, thank you. |
|
Given this is a big refactor how far down the line is it. Is it close to being merge-worthy? @kieran-ryan as we're doing a lot of other big changes in other flavours so would be good to get this in if we can |
# Conflicts: # python/gherkin/parser.py
8ae3c0d to
c026fe6
Compare
c026fe6 to
370f944
Compare
|
I've fixed the remarks around not exiting from the loop early. The implementation is a bit awkward as python doesn't have a do-while construct, but this should work and seems to satisfy ruff. |
🤔 What's changed?
Token.detachmethod in generated parser codeblacktoruffruff check gherkin/parser.py --select=I001)or Falselogic from conditionals - RET505 (ruff check gherkin/parser.py --select=RET505)orstatements withanycallelsestatement and nesting proceeding by conditionals that wouldreturnfrom the enclosing function⚡️ What's your motivation?
blackcode formatter to the python codebase #286match_token_at_'x'methods to just 4SyntaxErrorwould be raised if standardised to 4 spaces without handling (as per this pull request)ruffis monorepo-friendly, with hierarchical and cascading configuration - which is ideal for this repository: allowing configuration to be stored within thepythondirectory while allowing pre-commit, IDEs and commands run from the root of the repositoryblack,flake8,isort,pyupgradelinters and formatters toruffpytest-dev/pytest-bdd#758)or Falseis redundant - assume added as a safeguard where the proceeding args are not present (defaults to just ‘False’ in that case) pots generation - however the unit tests protect against this, failing if the args aren’t generatedanycalls against a comma-separate iterable compared to a series oforstatements where it can't be applied on every lineelseis redundant (superflous-else-return - RET505)useless-expression(B018)token.detach- updated code invokes appropriately though this doesn't actually alter behaviour (being a no-operation method) though conforms to intention and other parser implementation🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
Thoughts whether a
CHANGELOGentry is warranted?To evaluate changes are formatted correctly:
Open a codespace (or locally alternatively):
Regenerate all parser implementations:
From a separate terminal window, install the pre-commit hook and validate all Python code is formatted (including the generated parser code):
Run Python unit and acceptance tests to validate no regression in the generated parser implementation:
Have skipped formatting on
state_commentstringIntend to update GitHub Actions workflow in a follow up pull request to validate, or fully assess use of pre-commit-ci with this polyglot repo
📋 Checklist: