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

Decide what to do about B008 #738

Open
callumforrester opened this issue Aug 9, 2024 · 1 comment
Open

Decide what to do about B008 #738

callumforrester opened this issue Aug 9, 2024 · 1 comment

Comments

@callumforrester
Copy link
Contributor

B008 discourages function calls in default arguments e.g.

def foo(bar = bar_factory()): ...

This is a pattern commonly used in our codebase, such as inject in the link below. I think we're expecting to continue it even after lazy devices are supported (see #483), so plans would look something like:

def my_plan(x: Motor = i03.x()): ...

This issue is to discuss whether we should configure our projects to ignore the error and allow this behaviour because we know best, or follow ruff best practices and find another way to inject devices.

I'm going to throw in an early vote for the latter.

Originally posted by @callumforrester in #737 (comment)

@stan-dot
Copy link
Contributor

our specific use case is the device-singleton one, and the linked ruff page says this:
If the use of a singleton is intentional, assign the result call to a module-level variable, and use that variable in the default argument:

which is consistent with how the i22 stopflow plan uses PANDA = inject("panda1")

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

No branches or pull requests

2 participants