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 parser.py to use consistent arguments #369

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

bbayles
Copy link
Contributor

@bbayles bbayles commented Jun 21, 2024

This PR doesn't add any functionality, so I'll understand if you'd rather not take it. But I often found myself scrolling back and forth between sections of parser.py to look to see how a certain tag parser was called, and decided to try to make everything consistent.

The parse function now loops over the lines, checks for known tags, and always calls a parse function with these arguments:

  • line
  • lineno
  • data
  • state
  • strict

The parse functions accept all of the arguments as keywords, and if they don't need them, they don't act on them. All state / data updating logic is handled inside the parse functions.

I find that this makes the parse loop easier to think about, and it makes the process of adding support for new tags easier.

Copy link
Contributor

@leandromoreira leandromoreira left a comment

Choose a reason for hiding this comment

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

thanks for all the hard work, i love it, maybe for the future we use a paramsObject instead of kwargs

@mauricioabreu
Copy link
Member

Amazing job @bbayles
Could you rebase please? Then I can merge it immediately.

@bbayles
Copy link
Contributor Author

bbayles commented Jun 28, 2024

Should be one clean commit now - thanks!

@mauricioabreu mauricioabreu merged commit 48893fd into globocom:master Jun 28, 2024
@bbayles bbayles deleted the startswith-consistent branch June 28, 2024 18:10
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.

3 participants