summaryrefslogtreecommitdiff
path: root/astroid/helpers.py
Commit message (Collapse)AuthorAgeFilesLines
* Move from % syntax to format or f-stringsPierre Sassoulas2021-02-171-3/+3
| | | | This is possible with python 3.6
* Update copyright noticehippo912021-02-151-0/+1
|
* New copyright noticeshippo912020-12-271-0/+3
|
* Add None check on inferred_nodeSimon Hewitt2020-12-241-0/+1
|
* Squash one-off inference utility functions to help reduce recursion errors ↵Bryce Guinta2020-06-231-1/+19
| | | | | | | (#804) This also makes debugging a lot simpler reducing the complexity of the function stack.
* Fix exception causes in helpers.pyRam Rachum2020-06-191-4/+4
|
* Add missing copyright annotations for the past releasesClaudiu Popa2020-04-271-1/+1
|
* Infer the __len__ result of a subclass of an integerClaudiu Popa2020-03-101-2/+11
| | | | | Rather than failing the inference altogether, we can infer the default int value for subclasses of ints.
* Pass an inference context to `metaclass()` when inferring an object typeClaudiu Popa2019-10-181-1/+1
| | | | | | | | | This should prevent a bunch of recursion errors happening in pylint. Also refactor the inference of `IfExp` nodes to use separate contexts for each potential branch. Close PyCQA/pylint#3152 Close PyCQA/pylint#3159
* Fix lint warningsClaudiu Popa2019-10-111-0/+1
|
* Fix linting errorsClaudiu Popa2019-09-111-1/+1
|
* Instances of exceptions are inferred as such when inferring in non-exception ↵Claudiu Popa2019-05-211-1/+1
| | | | | | | | context This allows special inference support for exception attributes such as `.args`. Close PyCQA/pylint#2333
* Add a method to the manager to retrieve the builtins moduleClaudiu Popa2019-01-191-1/+1
|
* Initial formatting of astroidClaudiu Popa2018-10-021-23/+31
|
* infer_call_result can raise InferenceError so make sure to handle that for ↵Claudiu Popa2018-07-311-5/+1
| | | | | | | | | | | the call sites where it is used infer_call_result started recently to raise InferenceError for objects for which it could not find any returns. Previously it was silently raising a StopIteration, which was especially leaking when calling builtin methods. Since it is after all an inference method, it is expected that it could raise an InferenceError rather than returning nothing. Close PyCQA/pylint#2350
* Update the copyright noticesastroid-2.0Claudiu Popa2018-07-151-2/+3
|
* Fix lintingClaudiu Popa2018-06-141-5/+4
|
* Fix len builtin for instances of str or bytesBryce Guinta2018-03-151-1/+2
| | | | | A ClassDef of str or bytes may have the same qname as a Const value of str or bytes causing an AttributeError in len builtin inference
* Locally import FrozenSet node to avoid circular importBryce Guinta2018-03-111-1/+2
|
* Implement inference for len builtinBryce Guinta2018-03-111-0/+42
| | | | Close #112
* Fix the docstring and the commentsClaudiu Popa2018-03-101-4/+4
|
* Rewrite the object_isinstance and object_issubclass helpers to rely on ↵Claudiu Popa2018-03-101-35/+23
| | | | common code
* Add brain inference support for the `issubclass` builtinClaudiu Popa2018-03-101-0/+35
| | | | This is in a similar vein with the `isinstance` builtin, with minor changes.
* Replace handling of AstroidError with MroErrorClaudiu Popa2018-03-051-2/+0
| | | | | I'm not sure why AstroidError was added in the first place, as this is the most general exception in astroid.
* Make sure to handle Uninferable by returning it rather than returning an ↵Claudiu Popa2018-03-051-2/+2
| | | | exception
* Add helper function for doing isinstance checks on astroid inferred nodesBryce Guinta2018-03-021-0/+35
|
* Fix lint errorsBryce Guinta2018-02-261-2/+2
|
* Remove Python 2 branches, assume we always run on Python 3Claudiu Popa2018-02-211-10/+4
|
* Remove unreachable codeClaudiu Popa2017-12-151-1/+0
|
* Fix lint warningsClaudiu Popa2017-10-121-3/+5
|
* Even more granular copyrights (thanks to copyrite)Claudiu Popa2016-07-221-2/+3
|
* Keep a consistent copyright notice across the board.Claudiu Popa2016-07-191-0/+2
|
* Now is_subtype / is_supertype raises an internal exception when a type ↵Claudiu Popa2016-06-031-2/+2
| | | | | | | | hierarchy can't be determined It used to return Uninferable, but no call site was actually taking care of this potential return. It is better though to simply raise an exception and to let the call sites to handle them in which way they want to.
* Convert all files to new license headerCeridwen2016-05-161-184/+170
|
* Rename Uninferable and instantiate_class, fix broken tests, improveCeridwen2015-11-061-5/+5
| | | | | | | | | | | testing. * Rename YES to Uninferable * Rename instanciate_class to instantiate_class. * Use six in test_namedtuple_advanced_inference. * Fix test_file_from_module failure on PyPy. * Add enum34 to unittest_brain. * Add unittest_brain dependencies tox.ini.
* Update the docstring of object_type in order to make it clearer for its ↵Claudiu Popa2015-10-291-2/+4
| | | | actual purpose.
* Add support for indexing containers with instances which provides an ↵Claudiu Popa2015-10-221-0/+24
| | | | | | | | __index__ returning-int method. This patch moves _class_as_index to helpers, where it becames class_instance_as_index. Also, it instantiates its own call context, which makes certain idioms with lambdas to work.
* Add tests for aliasesCeridwen2015-08-211-1/+1
|
* Convert line endings for some files back to DOSCeridwen2015-08-151-158/+158
|
* Merge main into defaultCeridwen2015-08-141-7/+9
|\
| * Move InferenceContext and CallContext into astroid.contextClaudiu Popa2015-08-121-1/+2
| | | | | | | | | | | | | | In order to reduce circular dependencies between components, CallContext is moved into a new module, astroid.context. At the same time, for increasing the cohesion inside astroid.bases, InferenceContext was moved as well into astroid.context.
| * Move YES to astroid.util.Claudiu Popa2015-08-091-4/+5
| | | | | | | | | | | | | | YES is needed by other components of astroid, components which aren't necessarily related to astroid.bases. In order to reduce circular interdependencies between components, YES is moved into a new module, tailored for various *utilities*.
| * Return YES if no types could be deduced for the type builtin.Claudiu Popa2015-08-021-1/+1
| |
* | Node constructors almost finished except for two bugsCeridwen2015-07-081-156/+156
|/
* Add helpers.is_supertype and helpers.is_subtype, two functions for checking ↵Claudiu Popa2015-06-261-16/+77
| | | | if an object is a super/sub type of another.
* Add astroid.helpers, a module of various useful utilities which don't belong ↵Claudiu Popa2015-06-241-0/+95
yet into other components. Added *object_type*, a function which can be used to obtain the type of almost any astroid object, similar to how the builtin *type* works.