| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
| |
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
|
| |
|
|
|
|
|
| |
* Add new if guard helper methods
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
|
|
|
|
| |
* Add metadata to yield point.
* Add ChangeLog.
|
|
|
|
| |
* Move protocol match tests to separate class
* Don't infer MatchAs in assigned_stmts if pattern is not None
|
|
|
|
|
|
|
| |
* Fix issues when inferring match variables
* Fix extract_node for MatchCase
* Typing improvements
* Fix pylint issues (no-name-in-module)
* Use PY310_PLUS instead of sys.version_info
|
| |
|
|
|
|
| |
* Fix link in license header
* Fix link to cpython
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
See https://github.com/PyCQA/astroid/pull/1069\#issuecomment-865206120
|
|
|
|
|
|
| |
* Arguments - remove default init values
* Fix raw_building.build_function
* Use Arguments.postinit
* Add kwonlyargs
|
|
|
|
|
| |
Re-add 'ex' in good name
Fix a typo rrue = true
|
| |
|
| |
|
|
|
|
| |
See https://github.com/PyCQA/astroid/pull/1045\#discussion_r654575507
|
|
|
|
| |
See https://github.com/PyCQA/astroid/pull/1045\#discussion_r654572722
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
These tests left state in to the astroid manager that caused behavioural
changes in various other tests run after them, such as test failures if
unittest_brain ran after unittest_manager in the same test session. This
change attempts to fix these inter-test dependencies.
|
| |
|
|
|
|
| |
And add PY3X type constants in it.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
* Fix MatchClass fields
* Add types to Match fields
* Remove unnecessary Match get_children methods
* Fix test variable name
* Add tests for Match get_children
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
| |
|
| |
|
|
|
|
|
|
|
| |
* Improve support for Pattern Matching
* Fix lineno and col_offset
* Add string representation for match nodes
* Add NoChildrenMixin
* Add example nodes in docstrings
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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)
|
|
|
|
| |
* Add initial support for pattern matching py310
* Add typing_extensions
|
|
|
|
|
| |
transformations (#975)
* Fix six.with_metaclass transformation so it doesn't break user defined transformations
|
|
|
|
|
|
|
|
|
|
|
|
| |
* [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.16.0 → v2.18.2](https://github.com/asottile/pyupgrade/compare/v2.16.0...v2.18.2)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
|
|
|
|
|
| |
* Fix detection if a given module is relative to the specified file or package
* Remove obsolete suppression of false-positive "no-member"
* Add missing imports, do not instantiate PathFinder.
|
|
|
|
|
|
| |
Ref #485. To avoid additional breakage, we optionally extend is_abstract
to consider functions whose body is any raise statement (not just raise
NotImplementedError)
|
| |
|
|
|
|
|
|
|
|
|
| |
Ref #663. This test did not actually check for regression of the issue
fixed in 55076ca0 (i.e. it also passed on c87bea17 before the fix was
applied). Additionally, it over-specified the behaviour it was
attempting to check: whether the value returned from the context manager
was Uninferable was not directly relevant to the test, so when this
value changed due to unrelated fixes in inference, this test failed.
|
|
|
|
|
| |
Ref #485. If the function was inferred (unlike many compiler-builtins)
and it contains no Return nodes, then the implicit return value is None.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Fix inference cycle in getattr when a base is an astroid.Attribute
Ref #904. `getattr` attempts to find values on `self.ancestors`, which
infers each node listed in `self.bases`. Removing or resetting the
context passed to ancestors allows it to infer the nodes, but opens up
the possibility of cycles through recursive definitions. We should be
able to infer the value of the base node correctly as a `ClassDef`. The
root of this issue stems from the fact that `infer_attribute` attempts
to temporarily set `context.boundnode`, but when unwrapping its changes
it sets the `boundnode` to `None` instead of its previous value, which
loses state and causes the inference of the `Attribute` node to have a
duplicate key: once when looking up the class definition (which should
have `boundnode = None`), and once when inferring the (other) attribute
value (which should not have `boundnode = None`)
* Update changelog
|