summaryrefslogtreecommitdiff
path: root/astroid/brain
Commit message (Collapse)AuthorAgeFilesLines
* Bump astroid to 2.6.4, update changelogv2.6.4fix-4623-generator-raised-stop-iterationPierre Sassoulas2021-07-1930-30/+30
|
* Bump astroid to 2.6.3, update changelogv2.6.3Pierre Sassoulas2021-07-1930-9/+34
|
* Make TypedDict instance callableMarc Mueller2021-07-191-3/+17
|
* Handle the case where node is a Module in brain_builtin_inferencePierre Sassoulas2021-07-091-1/+3
| | | | Closes https://github.com/PyCQA/pylint/issues/4671
* Fix the docstring for context in brain_builtin_inferencePierre Sassoulas2021-07-061-3/+3
|
* Fix copyright links (#1084)Marc Mueller2021-07-0140-44/+44
| | | | * Fix link in license header * Fix link to cpython
* Bump astroid to 2.6.2, update changelogv2.6.2Pierre Sassoulas2021-06-301-1/+1
|
* Catch the StopIteration that result from PEP-479 or add default value in ↵Pierre Sassoulas2021-06-307-29/+50
| | | | | | | | | ``next`` (#1081) * Catch the StopIteration that result from PEP-479 StopIteration exceptions raised directly or indirectly in coroutines and generators are transformed into RuntimeError exceptions for python 3.7+.
* Bump astroid to 2.6.1, update changelogv2.6.1Pierre Sassoulas2021-06-291-1/+1
|
* Add dict as base for TypedDict (#1074)Marc Mueller2021-06-251-0/+1
|
* Bump astroid to 2.6.0, update changelogv2.6.0Pierre Sassoulas2021-06-221-4/+4
|
* Rename non obvious PY3X constant to PY3X_PLUSPierre Sassoulas2021-06-216-24/+24
| | | | See https://github.com/PyCQA/astroid/pull/1069\#issuecomment-865206120
* Simplification because AstroidManager is a singleton/borgPierre Sassoulas2021-06-1943-132/+155
|
* Create a file for the global manager defined in astroid.__init__.pyPierre Sassoulas2021-06-1940-40/+54
|
* Import directly from modules in astroid.brain.*Pierre Sassoulas2021-06-1932-230/+259
|
* Remove useless APi for astroid/brainPierre Sassoulas2021-06-191-3/+0
|
* Move 'register_module_extender' in astroid.brain where it's usedPierre Sassoulas2021-06-1928-40/+76
|
* Rename astroid.constants to astroid.constPierre Sassoulas2021-06-196-6/+6
| | | | See https://github.com/PyCQA/astroid/pull/1045\#discussion_r654572722
* Remove PY36 constants, we always have PY36Pierre Sassoulas2021-06-174-83/+55
|
* Create a astroid.constants.py to avoid circular importsPierre Sassoulas2021-06-178-28/+9
| | | | And add PY3X type constants in it.
* Import exceptions from astroid.exceptions to avoid circular importsPierre Sassoulas2021-06-1510-46/+40
|
* Improve inference of Enum members called "name" and "value" (#1020)Andrew Haigh2021-06-131-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | * Add DynamicClassAttribute to list of properties DynamicClassAttribute is a descriptor defined in Python's Lib/types.py which changes the behaviour of an attribute depending on if it is looked up on the class or on an instance. * Add fake "name" property to enum.Enum subclasses Ref PyCQA/pylint#1932. Ref PyCQA/pylint#2062. The enum.Enum class itself defines two @DynamicClassAttribute data-descriptors "name" and "value" which behave differently when looked up on an instance or on the class. When dealing with inference of an arbitrary instance of the enum class, e.g. in a method defined in the class body like: class SomeEnum(enum.Enum): def method(self): self.name # <- here we should assume that "self.name" is the string name of some enum member, unless the enum itself defines a "name" member. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Prepare for 2.5.8 release (#1013)v2.5.8Pierre Sassoulas2021-06-072-2/+2
|
* Update copyright notice for 2.5.7v2.5.7Pierre Sassoulas2021-05-296-5/+11
|
* Fix unhandled AstroidSyntaxError raised by infer_named_tuple brain (#929)Andrew Haigh2021-05-291-2/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix uncaught AstroidSyntaxErrors in namedtuple brain Ref #920. This adds a test suite and updates the infer_named_tuple brain with some additional behaviours expected by `collections.namedtuple`, specifically about rejecting invalid type and field names. Some of these cases inferred as namedtuples/`ClassDef` when they would have raised `ValueError` and some of these raise unhandled `AstroidSyntaxError`s due to attempts to parse class fakes with type names that would have raised `ValueError`. For example: from collections import namedtuple Tuple = namedtuple('X', 'abc abc') # Traceback (most recent call last): # ... # ValueError: Encountered duplicate field name: 'abc' import astroid node = astroid.extract_node(""" from collections import namedtuple Tuple = namedtuple('X', 'abc abc') Tuple """) next(node.infer()) # <ClassDef.X l.3 at 0x...> from collections import namedtuple Tuple = namedtuple('123', 'abc') # Traceback (most recent call last): # ... # ValueError: Type names and field names must be valid identifiers: '123' import astroid node = astroid.extract_node(""" from collections import namedtuple Tuple = namedtuple('123', 'abc') Tuple """) next(node.infer()) # Traceback (most recent call last): # ... # KeyError: (<function infer_named_tuple at 0x...>, <Call l.3 at 0x...>) # # During handling of the above exception, another exception occurred: # # Traceback (most recent call last): # ... # File "<unknown>", line 2 # class 123(tuple): # ^ # SyntaxError: invalid syntax # # The above exception was the direct cause of the following exception: # # Traceback (most recent call last): # ... # astroid.exceptions.AstroidSyntaxError: Parsing Python code failed: # invalid syntax (<unknown>, line 2)
* Fix six.with_metaclass transformation so it doesn't break user defined ↵Artsiom Kaval2021-05-291-0/+1
| | | | | transformations (#975) * Fix six.with_metaclass transformation so it doesn't break user defined transformations
* Fix crash on random.sample brain (#993)Andrew Haigh2021-05-221-0/+2
| | | | | | | | | | | | | * Add test of crash on random.sample inference Ref #922 * Fix crash in brain for random.sample Fixes #922. A combination of changes in 79d5a3a7 and 77e205dc meant that the node cloning helper could be given an EvaluatedObject, which doesn't present the same __init__ signature as NodeNG. * Update changelog
* Inferring property fields in a class context when metaclass is present (#941)Andrew Haigh2021-05-151-0/+10
| | | | | | | | | | | | | | | | | | * Add tests of failing property inference Ref #940 * Fix inference of properties in a class context Ref #940. If we are accessing an attribute and it is found on type(A).__dict__ *and* it is a data descriptor, then we resolve that descriptor. For the case of inferring a property which is accessed as a class attribute, this equates to the property being defined on the metaclass (which may be anywhere in the class hierarchy). * Fix inference of Enum.__members__ property for subclasses Ref PyCQA/pylint#3535. Ref PyCQA/pylint#4358. This updates the namedtuple/enum brain to add a dictionary for __members__
* [pre-commit.ci] pre-commit autoupdate (#985)pre-commit-ci[bot]2021-05-111-3/+3
| | | | | | | | | | | | | | | | | | * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/asottile/pyupgrade: v2.13.0 → v2.15.0](https://github.com/asottile/pyupgrade/compare/v2.13.0...v2.15.0) - https://github.com/ambv/black → https://github.com/psf/black - [github.com/psf/black: 20.8b1 → 21.5b1](https://github.com/psf/black/compare/20.8b1...21.5b1) - [github.com/pre-commit/mirrors-prettier: v2.2.1 → v2.3.0](https://github.com/pre-commit/mirrors-prettier/compare/v2.2.1...v2.3.0) - https://gitlab.com/pycqa/flake8 → https://github.com/PyCQA/flake8 - [github.com/PyCQA/flake8: 3.9.0 → 3.9.2](https://github.com/PyCQA/flake8/compare/3.9.0...3.9.2) * Update requirements file * Black changes Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
* Fix scope lookup of "type" for type inference brainAndrew Haigh2021-05-021-1/+2
|
* Fix overzealous inference of "type" in subscript contextsAndrew Haigh2021-05-021-1/+3
| | | | | | | | | Ref PyCQA/pylint#4083. Ref PyCQA/pylint#4387. When used in a nodes.Subscript, an existing inference_tip was set for Name nodes matching called type. However, when this name was redefined this led to false-positive typecheck errors in pylint such as invalid-sequence-index due to the argument being inferred as builtins.type and inference_tip preventing any further inference.
* Fix lambda used instead of a functionPierre Sassoulas2021-05-012-4/+8
|
* Fix function call as default argumentPierre Sassoulas2021-05-011-1/+4
|
* Fix calling getattr with a constant attribute valuePierre Sassoulas2021-05-011-1/+1
|
* Prepare for 2.5.4 releaseastroid-2.5.4Pierre Sassoulas2021-04-2410-6/+14
|
* Add __init__ to astroid.brain packageMarc Mueller2021-04-244-6/+6
|
* Fix crash when evaluating typing.NamedTuple (#956)Marc Mueller2021-04-211-1/+2
|
* Add inference tip for ``typing.Tuple`` (#948)Marc Mueller2021-04-211-0/+43
|
* Enable checks for and fix useless suppressionPierre Sassoulas2021-04-192-2/+2
|
* Add an isort configuration in setup.cfg and apply itPierre Sassoulas2021-04-1923-59/+46
| | | | Except on astroid/__init__.py because of circular imports
* Add autoflake except where it would break the codePierre Sassoulas2021-04-194-6/+0
|
* Fix pylint warnings in astroid/brain/brain_giPierre Sassoulas2021-04-191-3/+8
|
* Fix pylint warnings in astroid/brain/brain_typing.pyPierre Sassoulas2021-04-191-7/+6
|
* Fix pylint warnings in astroid/brain/brain_fstringsPierre Sassoulas2021-04-191-1/+1
|
* Fix pylint warnings in astroid/brain/brain_namedtuple_enumPierre Sassoulas2021-04-191-5/+5
|
* Fix pylint warnings in astroid/brain/brain_sixPierre Sassoulas2021-04-191-1/+2
|
* Fix pylint warnings in astroid.brain.brain_builtin_inferencePierre Sassoulas2021-04-191-9/+9
|
* Fix inconsistent return statementsPierre Sassoulas2021-04-191-2/+3
|
* Fix useless return at end of function or methodPierre Sassoulas2021-04-191-2/+1
|
* Fix no exception type(s) specified on getattrPierre Sassoulas2021-04-191-1/+1
|