- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 306
          Restore setting a Call as a base for classes from six.with_metaclass()
          #2049
        
          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
  
    Restore setting a Call as a base for classes from six.with_metaclass()
  
  #2049
              Conversation
| @Pierre-Sassoulas do I remember correctly that you develop on Linux? The failing test passes for me on MacOS, so I'm wondering if there are different wheels for  | 
| Does this resolve #1735 as well? | 
| 
 No, it doesn't. But I haven't worked out what the root issue is there--is it that it should expect  | 
| I'm unsure. I'm not familiar with that part of astroid, plus I've never used six. | 
Harden support for using enums as metaclasses. Fixes the crash in pylint-dev/pylint#5935 by adopting the check for not-none bases as in ClassDef._inferred_bases without recausing the false positive reported in pylint-dev/pylint#7506, which requires correct bases.
d9b29c5    to
    aea9410      
    Compare
  
    | Codecov Report
 Additional details and impacted files@@            Coverage Diff             @@
##             main    #2049      +/-   ##
==========================================
- Coverage   92.82%   92.82%   -0.01%     
==========================================
  Files          95       95              
  Lines       11066    11065       -1     
==========================================
- Hits        10272    10271       -1     
  Misses        794      794              
 Flags with carried forward coverage won't be shown. Click here to find out more. 
 | 
| self.assertEqual(inferred.name, "B") | ||
| self.assertIsInstance(inferred.bases[0], nodes.Name) | ||
| self.assertEqual(inferred.bases[0].name, "C") | ||
| self.assertIsInstance(inferred.bases[0], nodes.Call) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change restores the prior results before #1622.
| Yes, I'm on linux, do you want me to test something ? | 
| 
 We  | 
| I can't reproduce the fail either:  | 
…s` (#2049) Harden support for using enums as metaclasses. Fixes the crash in pylint-dev/pylint#5935 by adopting the check for not-none bases as in ClassDef._inferred_bases without recausing the false positive reported in pylint-dev/pylint#7506, which requires correct bases. (cherry picked from commit b5ebf99)
…s` (#2049) (#2067) Harden support for using enums as metaclasses. Fixes the crash in pylint-dev/pylint#5935 by adopting the check for not-none bases as in ClassDef._inferred_bases without recausing the false positive reported in pylint-dev/pylint#7506, which requires correct bases. (cherry picked from commit b5ebf99) Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Type of Changes
Description
Harden support for using enums as metaclasses with
six.with_metaclass(...)syntax.Fixes the crash in pylint-dev/pylint#5935 by adopting the check for not-none bases as in
ClassDef._inferred_baseswithout recausing the false positive reported in pylint-dev/pylint#7506, which requires having correct bases. Here is the analogous existing code:https://github.com/PyCQA/astroid/blob/91fd7b95fc943676f5aafb2d0ee881c4e167fa04/astroid/nodes/scoped_nodes/scoped_nodes.py#L3001-L3006
Essentially reverts #1622 (Sorry! It was my best understanding at the time, and at least we were trading a crash for a false positive.)
Refs pylint-dev/pylint#5935 (crash: tested here with test_metaclass_generator_hack_enum_base)
Refs pylint-dev/pylint#7506 (false positive: will open a pylint regression test PR shortly)