-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Cleanup unnecessary @staticmethod annotations #3324
Comments
@balopat I'd like take this up. Should changes be made everywhere |
Hi @shouri007 - thank you for taking this up, it's yours! Regarding mac we don't have the instructions but we do have a task to document it - I'm working on a mac myself - it is definitely possible. If you're interested taking that up as well, let me know - otherwise if you get stuck (I just use venv personally and |
Yes, I believe so! |
Wouldn't this be a pretty big breaking change? For example, all calls to CircuitDag.make_node would need to be changed to make_node. Personally I like module functions more than static methods, but do you feel comfortable with going forward with this? |
Here's an option: we clean up all of the private functions that start with "_". That way we can feel safer that people using Cirq won't be broken. But if you feel comfortable just changing them all over, I can implement the refactor. |
There is a @deprecated annotation cirq uses for depreciating things over time, to reduce breakages. Not sure what the policy is for private functions. It may be a judgment call, case by case. |
I'm willing to add @deprecated to all of the public static methods. Do you think I should? I could:
That way the user could update their code to use the module function before we remove the static method completely |
|
We probably want to retain discoverability associated with having most names at the top level. There are at least two ways of eliminating |
The PR to refactor the private methods is ready (#4231). As far as @classmethod is concerned, check out this quote from the styleguide: Use classmethod only when writing a named constructor or a class-specific routine that modifies necessary global state such as a process-wide cache. It seems that since static methods don't "modif[y] necessary global state", the styleguide suggests that we should not refactor them into class methods. I feel like the remaining work (if any) associated with this bug will require a pretty deep level of familiarity with the concerns of the remaining static methods. So I suggest we remove the "good first issue" tag. Also, I will move on to other issues. |
Thanks @thanacles - that's a fair assessment! |
Refactor private static methods to module functions. Related to #3324.
Refactor private static methods to module functions. Related to quantumlib#3324.
This was partially cleaned up a while ago. Remaining references are not going to get cleaned up due to backwards compatibility issues. Closing this issue. |
Context: #3322 (comment)
The text was updated successfully, but these errors were encountered: