Skip to content

Make ControllerVector generic on Controller_T#326

Open
shihab-dls wants to merge 1 commit intomainfrom
make_controller_vector_generic
Open

Make ControllerVector generic on Controller_T#326
shihab-dls wants to merge 1 commit intomainfrom
make_controller_vector_generic

Conversation

@shihab-dls
Copy link
Contributor

closes #325

@shihab-dls shihab-dls requested a review from GDYendell February 23, 2026 16:53
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.86%. Comparing base (dbb85c4) to head (56e4c85).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #326      +/-   ##
==========================================
+ Coverage   90.85%   90.86%   +0.01%     
==========================================
  Files          70       70              
  Lines        2547     2550       +3     
==========================================
+ Hits         2314     2317       +3     
  Misses        233      233              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

from fastcs.controllers import BaseController # noqa: F401

Controller_T = TypeVar("Controller_T", bound="BaseController") # noqa: F821
"""Generic `Controller` class that an unbound method must be called with as `self`"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason not to define this in base_controller.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since it's used in methods and controllers, I thought util was most sensible, but I guess methods importing from controllers is not that strange; is this a nit?

Copy link
Contributor

@GDYendell GDYendell Feb 26, 2026

Choose a reason for hiding this comment

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

Not even a nit. I am not sure what is best.

util.py is kind of intended to be a place that everything can import from. If it itself needs to import from the modules then that breaks. You couldn't import util from the controllers module now because it won't be fully initialised, although because of the if TYPE_CHECKING it is OK

I think it makes sense to put it in controllers somewhere. It could even be defined in __init__.py.

Would you prefer where it is currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I agree with you, utils importing from a sub-directory is not ideal; I liked the idea of putting Controller_T in controllers __init__, but this makes it partially resolved for methods, which forces it into the if TYPE_CHECKING condition, which is no good, as we need it to exist at runtime. Keeping it in utils, although not an intended use of a utils file, lets us grab Controller_T in both methods and controllers at runtime, and type check Controller_T during linting due to the IF TYPE_CHECKING condition on BaseController. Although, this would break if we started enforcing import contracts in the future... What do you think?

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.

Make ControllerVector generic on a Controller

2 participants