Skip to content

Refactoring of Generators #118

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

rpgoldman
Copy link
Contributor

Draft of refactoring of Popper's generators. Adds an abstract class that is the parent of the three alternate generators. loop.py now imports all three of them, and adds Popper.select_generator() method to encapsulate the choice process.

This is very unlikely to be ready for adoption, but it seems not to break anything, based on test runs, and I hoped it would be of interest.

I did this to make it possible to tailor generators, but it also has the advantage of making it possible for type checkers and other linters to check the generator code and how it's used in the rest of Popper.

I added a couple of new type definitions into abs_generate.py, which caused a little fuss because these use type definitions from popper.util. Although this is circular, it's not a problem when type-checking (see the wrapping of imports at the head of abs_generate.py). But it's untidy; it would probably be more elegant to have a file of miscellaneous type definitions w/o code that could be loaded early in load order.

The diff is ugly, I'm afraid, because this was built on top of the linter improvements in #115. If that can be merged, then the diffs here would clean up.

rpgoldman added 8 commits May 12, 2025 15:22
Code formatting issues from the linter.

Pruned imports per linter

Provide more information in error-handler.

Replace error print statements with logging messages at error level.

Tweak error handling.
Removed mutable default values.
Removed equality comparisons against None.
Looking at the README in the PyCharm IDE, discovered that it incorrectly
referenced `print_prog_score`.  This is not a function, but a method on
`Settings`.
Change to explicitly make the default logging level be WARNING.
@rpgoldman
Copy link
Contributor Author

I am going to rewrite the history here and then force push it -- the history is a little ugly at present.

rpgoldman added 3 commits June 9, 2025 20:28
Add `resource_string.py` that provides a compatibility layer between
versions of Python that do and don't have the `pkg_resources` library,
removed in version 3.12.
Create two new methods, `build_encoding` and `init_solver` that encapsulate the set up of the solver.
Did this for my own purposes, but it simplifies the code, as well, and could be used later to reduce code duplication.
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.

1 participant