-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix for NamedTuple in method [WIP] #2553
Conversation
In lines 1654 and 741 we have: node.kind = GDEF # TODO locally defined namedtuple and when working with classes, we have (line 788) if self.is_func_scope() or self.type:
kind = MDEF
if self.is_func_scope():
kind = LDEF is it not related? (I must say I do not completely understand how the symbol table works). (The whole ad-hoc type creation ( |
From grepping it looks like the distinction between LDEF, MDEF and GDEF is minimal, and the kind is only really used in pretty_name() in strconv.py, to format the name somewhat differently for debug output. There are a few other places that compare them but treat all three the same. We could probably replace them with a single 'DEF' and everything would continue to work except we would have to fix a whole lot of tests that compare the debug output (node rendering IIRC). (The constants are also returned by kind_by_scope() and its return value is sometimes incorporated in symbol table nodes, but the only place where I see the kind retrieved from those nodes used is in strconv, and in a whole bunch of places that copy it into other nodes.) Maybe @davidfstr is interested in the ad-hoc class creation refactoring you suggest? (Before he introduced TypedDict there was only one place doing this stuff.) |
With respect to refactoring More details about the refactoring - in particular the call tree - are in this postponed proposal: #2198 |
There is one more thing about refactoring |
Beware, the first pass runs very early and under severe restrictions. It is
mostly just concerned with computing the set of module dependencies.
|
Yes, it also creates "stub" nodes for classes, so that they are "known" for type analyzer in second pass, thus avoiding |
Since we don't process imports during the first pass, you can't reliably detect references to things like |
Anyway, I'm just going to merge this after I've verified that the globals can't conflict. |
@JukkaL Regarding the current diff, it seems that simply NOT storing the info in |
(Whoops, left the WIP in the commit message. Oh well.) |
Fixes #2535.