igorcmoura / anitopy

Anime video filename parser in Python, based on Anitomy
Mozilla Public License 2.0
69 stars 19 forks source link

Refactor: remove use of singletons #15

Closed tylergibbs2 closed 1 year ago

tylergibbs2 commented 1 year ago

Pulls Elements and Tokens out into objects and passes them around while parsing to avoid the usage of singletons.

Implementation details:

Closes #11. See discussion there for the purpose of this PR.

Note: I'm getting 35/35 tests failed, but I was also getting that even before I made any changes. Please check locally.

igorcmoura commented 1 year ago

Thank you so much for this PR!

I was struggling with parser_number.py and parser_helper.py because I didn't want to pass the Elements and Tokens instances for all those functions. But looking at your implementation it seems fine.

About the failing tests: Those are ambiguous cases that Anitopy cannot parse (bonus points if you figure out how to parse some of them). They came from Anitomy and I decided to keep them. Maybe they should be renamed to something better to not confuse any more people.

tylergibbs2 commented 1 year ago

Thanks for the merge! I do agree it is a bit less nice to look at passing Elements and Tokens into those methods... I thought about pulling those methods out into separate classes, but I didn't want to make any changes that strayed from the goal of this PR and I also didn't want to assume how you would prefer it in your codebase.

igorcmoura commented 1 year ago

I've released version 2.2.0rc2 if you want to check if everything is alright before I do the final release.

tylergibbs2 commented 1 year ago

Did some quick tests with the RC and everything looked good to me! 👍