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

Refactor: factor-out usage of itertools.groupby from generate_identifier_pattern.py script #1836

Conversation

jayaddison
Copy link

@jayaddison jayaddison commented Apr 7, 2023

Refactors the generate_identifier_pattern.py script; initially this was done in order to experiment with removal of itertools.groupby code that flake8 pre-commit checks were complaining about (see #1835).

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@jayaddison jayaddison force-pushed the issue-1835/generate-identifier-script-refactor branch from 8f3803e to e647732 Compare April 7, 2023 19:05
@davidism
Copy link
Member

davidism commented Apr 7, 2023

The check is getting confused by the name reuse, this does not require a huge refactor. Changing b = list(b) to lb = list(b) fixes the warning. 090a5a9

@davidism davidism closed this Apr 7, 2023
@jayaddison
Copy link
Author

Thanks; that's fair reason, yep.

FYI: there is a single-character difference in the output produced by the refactor compared to the script as-is when I run it locally; the existing script emits a trailing minus symbol (range indicator).

That doesn't appear to produce any change-in-behaviour based on my testing in Py3.11 (I was briefly worried that it could allow the - character to appear in identifiers, or to exclude the preceding character from successfully matching, but those don't appear to be the case).

@jayaddison jayaddison deleted the issue-1835/generate-identifier-script-refactor branch April 7, 2023 21:44
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flake8 warning: B031: repeat usage of generator
2 participants