summaryrefslogtreecommitdiff
path: root/tests/unittest_brain.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove check for six tox-environmentMarc Mueller2021-04-241-7/+0
|
* Fix crash when evaluating typing.NamedTuple (#956)Marc Mueller2021-04-211-0/+26
|
* Add inference tip for ``typing.Tuple`` (#948)Marc Mueller2021-04-211-0/+13
|
* Fix import order in unittest_brain.pyPierre Sassoulas2021-04-191-8/+9
|
* Add an isort configuration in setup.cfg and apply itPierre Sassoulas2021-04-191-6/+2
| | | | Except on astroid/__init__.py because of circular imports
* Fix redefining name 'bases' from outer scopePierre Sassoulas2021-04-191-2/+1
|
* Fix Expression is assigned to nothingPierre Sassoulas2021-04-191-0/+1
|
* Fix Unused variable 'meth_inf'Pierre Sassoulas2021-04-191-1/+1
|
* Remove conditional for having pytest, we have pytestPierre Sassoulas2021-04-191-3/+0
|
* Remove python < 3.4 compatibility code for enum modulePierre Sassoulas2021-04-191-18/+0
|
* Fix issue #891Pierre Sassoulas2021-04-101-1/+1
| | | | Remove outdated COPYING and rename COPYING.LESSER
* Modify infernce tip for typing.Generic and typing.Annotated with ↵Marc Mueller2021-04-101-0/+50
| | | | | | | ``__class_getitem__`` (#931) * Modify infernce tip for typing.Generic and typing.Annotated with __class_getitem__ * Fix issue with slots caching * Clean typing.Generic from mro
* Better handling of generic aliases (#923)Marc Mueller2021-04-071-49/+167
| | | | | | * Better handling of generic aliases * Use qname for tests mro * Add inference for re.Pattern and re.Match * Add comments
* Use inference_tip for typing.TypedDict brain (#928)Marc Mueller2021-04-071-5/+2
|
* Bug pylint 4206 (#921)hippo912021-04-061-40/+250
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Takes into account the fact that inferring subscript when the node is a class may use the __class_getitem__ method of the current class instead of looking for __getitem__ in the metaclass. * OrderedDict in the collections module inherit from dict which is C coded and thus have no metaclass but starting from python3.9 it supports subscripting thanks to the __class_getitem__ method. * check_metaclass becomes a static class method because we need it in the class scope. The brain_typing module does not add a ABCMeta_typing class thus there is no need to test it. Moreover it doesn't add neither a __getitem__ to the metaclass * The brain_typing module does not add anymore _typing suffixed classes in the mro * The OrderedDict class inherits from C coded dict class and thus doesn't have a metaclass. * When trying to inherit from typing.Pattern the REPL says : TypeError: type 're.Pattern' is not an acceptable base type * The REPL says that Derived as ABCMeta for metaclass and the mro is Derived => Iterator => Iterable => object * Adds comments * Starting with Python39 some collections of the collections.abc module support subscripting thanks to __class_getitem__ method. However the wat it is implemented is not straigthforward and instead of complexifying the way __class_getitem__ is handled inside the getitem method of the ClassDef class, we prefer to hack a bit. * Thanks to __class_getitem__ method there is no need to hack the metaclass * SImplifies the inference system for typing objects before python3.9. Before python3.9 the objects of the typing module that are alias of the same objects in the collections.abc module have subscripting possibility thanks to the _GenericAlias metaclass. To mock the subscripting capability we add __class_getitem__ method on those objects. * check_metaclass_is_abc become global to be shared among different classes * Create a test class dedicated to the Collections brain * Rewrites and adds test * Corrects syntax error * Deque, defaultdict and OrderedDict are part of the _collections module which is a pure C lib. While letting those class mocks inside collections module is fair for astroid it leds to pylint acceptance tests fail. * Formatting according to black * Adds two entries * Extends the filter to determine what is subscriptable to include OrderedDict * Formatting according to black * Takes into account the fact that inferring subscript when the node is a class may use the __class_getitem__ method of the current class instead of looking for __getitem__ in the metaclass. * OrderedDict in the collections module inherit from dict which is C coded and thus have no metaclass but starting from python3.9 it supports subscripting thanks to the __class_getitem__ method. * check_metaclass becomes a static class method because we need it in the class scope. The brain_typing module does not add a ABCMeta_typing class thus there is no need to test it. Moreover it doesn't add neither a __getitem__ to the metaclass * The brain_typing module does not add anymore _typing suffixed classes in the mro * The OrderedDict class inherits from C coded dict class and thus doesn't have a metaclass. * When trying to inherit from typing.Pattern the REPL says : TypeError: type 're.Pattern' is not an acceptable base type * The REPL says that Derived as ABCMeta for metaclass and the mro is Derived => Iterator => Iterable => object * Adds comments * Starting with Python39 some collections of the collections.abc module support subscripting thanks to __class_getitem__ method. However the wat it is implemented is not straigthforward and instead of complexifying the way __class_getitem__ is handled inside the getitem method of the ClassDef class, we prefer to hack a bit. * Thanks to __class_getitem__ method there is no need to hack the metaclass * SImplifies the inference system for typing objects before python3.9. Before python3.9 the objects of the typing module that are alias of the same objects in the collections.abc module have subscripting possibility thanks to the _GenericAlias metaclass. To mock the subscripting capability we add __class_getitem__ method on those objects. * check_metaclass_is_abc become global to be shared among different classes * Create a test class dedicated to the Collections brain * Rewrites and adds test * Corrects syntax error * Deque, defaultdict and OrderedDict are part of the _collections module which is a pure C lib. While letting those class mocks inside collections module is fair for astroid it leds to pylint acceptance tests fail. * Formatting according to black * Adds two entries * Extends the filter to determine what is subscriptable to include OrderedDict * Formatting according to black * Takes into account AWhetter remarks * Deactivates access to __class_getitem__ method * OrderedDict appears in typing module with python3.7.2 * _alias function in the typing module appears with python3.7 * Formatting according to black * _alias function is used also for builtins type and not only for collections.abc ones * Adds tests for both builtins type that are subscriptable and typing builtin alias type that are also subscriptable * No need to handle builtin types in this brain. It is better suited inside brain_bulitin_inference * Adds brain to handle builtin types that are subscriptable starting with python39 * Formatting according to black * Uses partial function instead of closure in order pylint acceptance to be ok * Handling the __class_getitem__ method associated to EmptyNode for builtin types is made directly inside the getitem method * infer_typing_alias has to be an inference_tip to avoid interferences between typing module and others (collections or builtin) * Formatting * Removes useless code * Adds comment * Takes into account cdce8p remarks * Formatting * Style changes Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
* Prepare for 2.5.2 releaseastroid-2.5.2Pierre Sassoulas2021-03-281-1/+1
|
* Solves "Duplicates found in MROs" false positives. (#905, #916)Marc Mueller2021-02-281-0/+115
| | | | | | | * Adds inference support for all typing types that are defined through _alias function * Instead of creating a new class (by the mean of TYPING_TYPE_TEMPLATE) infer the origin class : i.e MutableSet = _alias(collections.MutableSet ...) origin is the class in collections module. Needs to add __getitem method on its metaclass so that is support indexing (MutableSet[T]). * Enable _alias mocking and testing only if python version is at least 3.7 Co-authored-by: hippo91 <guillaume.peillex@gmail.com>
* Upgrade copyrite noticePierre Sassoulas2021-02-281-0/+2
|
* Don't transform dataclass ClassVars (#914)Marc Mueller2021-02-281-0/+12
| | | Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Small improvementsMarc Mueller2021-02-281-3/+1
|
* Fix testsMarc Mueller2021-02-281-0/+3
|
* Improve typing.TypedDict inferenceMarc Mueller2021-02-281-0/+15
|
* Move from % syntax to format or f-stringsPierre Sassoulas2021-02-211-15/+11
| | | | This is possible with python 3.6
* Remove the # coding, since PEP3120 the default is UTF8Pierre Sassoulas2021-02-211-1/+0
|
* Update copyright noticehippo912021-02-151-1/+3
|
* Move the unit test to unittest_brain because it needs sixhippo912021-02-121-0/+28
|
* Adds missing includehippo912021-02-071-0/+1
|
* Merge branch 'master' into masterhippo912021-02-071-0/+55
|\
| * Julien palard mdk/class getitem (#885)hippo912021-01-241-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add missing __class_getitem__ to deque. * The __class_getitem__ method is added only for python versions above 3.9 * Adds two tests that ensure that __class_getitem__ method is not present for python versions prior to 3.9 but present for python versions above 3.9 * Reorganizes * Adds an entry * Add Julien Palard in copyright Co-authored-by: Julien Palard <julien@palard.fr>
| * Merge pull request #883 from hippo91/bug_pylint_4001hippo912021-01-231-0/+36
| |\ | | | | | | Bug pylint 4001
| | * Formatting according to blackhippo912021-01-201-2/+2
| | |
| | * Adds dochippo912021-01-191-0/+9
| | |
| | * Adds unittest for brain_type modulehippo912021-01-181-0/+27
| | |
| * | brain: Add `__class_getitem__` to `subprocess.Popen` starting from Python 3.9Damien Baty2021-01-181-0/+7
| |/ | | | | | | | | | | | | | | | | | | This is necessary for pylint to detect that `subprocess.Popen` is subscriptable, starting from Python 3.9 (see PyCQA/pylint#4034). $ python3.9 >>> import subprocess >>> subprocess.Popen.__class_getitem__ <bound method GenericAlias of <class 'subprocess.Popen'>>
* | Remove required_version for 3.6 and belowDavid Gilman2020-12-311-9/+0
| | | | | | | | We are now guaranteed to be running on 3.6+
* | Add tox support for six-less environmentsDavid Gilman2020-12-311-0/+7
| |
* | Remove six from astroidDavid Gilman2020-12-301-2/+10
|/
* New copyright noticeshippo912020-12-271-1/+2
|
* Do not crash when encountering starred assignments in enums.Claudiu Popa2020-12-261-0/+10
| | | | Close #835
* Remove dependency on imp.Peter Kolbus2020-11-271-2/+4
|
* Squash one-off inference utility functions to help reduce recursion errors ↵Bryce Guinta2020-06-231-0/+16
| | | | | | | (#804) This also makes debugging a lot simpler reducing the complexity of the function stack.
* Separate string and bytes classes patching (#807)Claudiu Popa2020-06-231-0/+15
| | | Fixes PyCQA/pylint#3599
* Do not crash with SyntaxError when parsing namedtuples with invalid labelClaudiu Popa2020-05-011-0/+12
| | | | Close PyCQA/pylint#3549
* Add missing copyright annotations for the past releasesClaudiu Popa2020-04-271-3/+11
|
* Infer the __len__ result of a subclass of an integerClaudiu Popa2020-03-101-4/+7
| | | | | Rather than failing the inference altogether, we can infer the default int value for subclasses of ints.
* Skip non ``Assign`` and ``AnnAssign`` nodes from enum reinterpretationClaudiu Popa2020-02-101-0/+15
| | | | Closes PyCQA/pylint#3365
* Allow inferring attributes of `HTTPStatus` callableClaudiu Popa2019-12-161-0/+9
| | | | Close PyCQA/pylint#3296
* Moved tests out of package directory (#704)Ashley Whetter2019-10-151-0/+1977