-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Remove monkey-patching of methods onto classes #679
Comments
Thanks for creating the issue @degustaf Yes, this is still a design goal that we'd want to achieve with If you're interested in helping, cherry-picking the refactoring for dropping the monkeypatch would be definitely amazing. |
Can someone provide some details on this please? But overall I just saw "contributor friendly" tag and wanted to see if I could be of any help. |
Hey @gyermolenko ! This might not be contributor friendly after all, as it requires going through https://github.com/PyCQA/astroid/tree/2.0 and bringing back into |
@DanielNoord made a start toward this by suggesting a new design where nodes don't need to know how to infer themselves in #2167 (with a new Then I suggested an alternative in #2171 where we keep the existing API and just define the methods on the classes where we expect them, and solve cyclic imports along the way. We have consensus that we'd like to fix this in an alpha of astroid 3.0, but we don't have consensus yet on which direction to take. I'd like to flow out all the concerns folks raised to make sure everything is sounded out before choosing a direction. Concerns with the infer_object()/
|
limit = AstroidManager.max_inferable_values |
AstroidManager()
and then use the global state. As said above, I don't see infer_object
as the final version of the inference system but I do see it as a clearer step towards having an inference system that can be instantiated on demand and without any shared state.
- JW: I didn't follow this one, hoping to grok it after DN's updates. I understand that global state jeopardizes parallelism, but that seems like an orthogonal problem to me. Do you have an example of how Create
infer_object
#2167 would help in this regard?
- JW: Do you have an example of how Create
infer_object
#2167 would help in this regard? I didn't grok this. - DN: See above. I don't like how we use
postinit
and have to see instance attributes as class-scope typed attributes to make things work formypy
. Mixins make this even worse. To me those types seem like an anti-pattern that we should try and avoid. Createinfer_object
#2167 doesn't fix this, but also doesn't make the problem worse.
DN: What I don't really like about keeping the existing API is that I don't see a clear path towards some of the existing issues we have. Although you showed that it does allow us to fix some of the cyclic imports etc. for me it just doesn't click how making one class/type responsible for everything improves the state of the codebase. I think separation of concerns would be better and makes it easier to tackle individual problems. Perhaps I'm too influenced by my day to day work but I tend to see astroid
as having a data and an application layer (with pylint
being the frontend if you want to complete this comparison). Separation between the data modelling layer and the layer that interacts with it feels more natural to me, but that might just be my own preference.
I hope to find time tonight to get back to this! My comment in #2210 is also somewhat related to my general ideas about |
I have added my comments to the list. Let's continue the discussion in comments from now on and not keep editing the original post by Jacob. |
Thanks, I really appreciate your taking the time to add notes! I'm hoping the silly bullet-point debate-flow-outline might help others follow the discussions we had across several PRs. 😄 I'll let this be my last post on the subject for a while, because if I drone on it could discourage other people from speaking up. 📣 I'm hearing the arguments for the Or not! But it's too early to know. Is this PR supposed to be the first PR in a series of PRs to fix multiprocessing? It seems to me like the wrong place to start. Or, in other words, it seems like only one person has a mental roadmap of how [*] just noticed that @DanielNoord edited the post to clarify that it's the "
Same as above, I'm not convinced this would be the only way to do that? I'd rather see at least some proof-of-concept of some element of removing global state and how infer_object() is necessary to make it work.
To avoid repeating myself :D...
I confess to not even being sure how this would work. A few lines of pseudocode would help, if you're up for it. What do people want with the astroid library if they don't want inference? I know there was a comment along these lines from PCManticore in #169 (comment), though. I think the most impactful intervention for new contributors would be continuing to use the good-first-issues label and ensuring we don't ask for big refactors along the way. (The str/repr PR in #2198 was a good experience, I felt!) |
This is fair. I think the counter-argument is why I am so hesitant for the other approach: I don't see the end-goal and only a fix for one particular issue. We have so many difficulties with getting
This is basically my argument above reworded in my opinion 😄 What is the end objective of that PR? And if there isn't one: shouldn't there be one?
I agree, I should have discussed this more clearly.
👍
I think this is more of a philosophical/design decision. Like I said, to me it feels like we should disconnect the data and the data-handling as they have different responsibilities.
See #2048. In the current setup I don't think we can parallelise what we should. That's an issue 😄
Well, in #1338 I know the author was trying to replace
Agreed! |
In this comment, @PCManticore stated that there was a plan to remove monkey-patching of methods onto classes. inference.py and protocols.py seem to suggest that this hasn't happened.
Is this still a design goal?
It looks to me like this would be a fairly mechanical change. I am assuming that since it hasn't happened yet, I am missing something. Is it simply a "haven't had time" issue?
The text was updated successfully, but these errors were encountered: