Releases: pylint-dev/astroid
v3.2.0
-
.pyi
stub files are now preferred over.py
files when resolving imports, (except for numpy).Closes pylint-dev/pylint#9185
-
igetattr()
returns the last same-named function in a class (instead of
the first). This avoids false positives in pylint with@overload
.Closes #1015
Refs pylint-dev/pylint#4696 -
Adds
module_denylist
toAstroidManager
for modules to be skipped during AST
generation. Modules in this list will cause anAstroidImportError
to be raised
when an AST for them is requested. -
Make
astroid.interpreter._import.util.is_namespace
only consider modules
using a loader set toNamespaceLoader
orNone
as namespaces.
This fixes a problem thatsix.moves
brain was not effective ifsix.moves
was already imported.Closes #1107
v3.1.0
- Include PEP 695 (Python 3.12) generic type syntax nodes in
get_children()
,
allowing checkers to visit them.
Refs pylint-dev/pylint#9193 - Add
__main__
as a possible inferred value for__name__
to improve
control flow inference aroundif __name__ == "__main__":
guards.
Closes #2071 - Following a deprecation period, the
names
arg to theImport
constructor and
theop
arg to theBoolOp
constructor are now required, and thedoc
args
to thePartialFunction
andProperty
constructors have been removed (call
postinit(doc_node=...)
instead.) - Following a deprecation announced in astroid 1.5.0, the alias
AstroidBuildingException
is removed in favor ofAstroidBuildingError
. - Include modname in AST warnings. Useful for
invalid escape sequence
warnings
with Python 3.12. RecursionError
is now trapped and logged out asUserWarning
during astroid node transformations with instructions about raising the system recursion limit.
Closes pylint-dev/pylint#8842- Suppress
SyntaxWarning
for invalid escape sequences on Python 3.12 when parsing modules.
Closes pylint-dev/pylint#9322
v3.0.3
-
Fix type of
UnicodeDecodeError.object
inferred asstr
instead ofbytes
.Closes pylint-dev/pylint#9342
-
Fix
no-member
false positives forargs
andkwargs
onParamSpec
under Python 3.12.Closes pylint-dev/pylint#9401
v3.0.2
What's New in astroid 3.0.2?
Release date: 2023-12-12
- Avoid duplicate inference results for some uses of
typing.X
constructs like
Tuple[Optional[int], ...]
. This was causing pylint to occasionally omit
messages likedeprecated-typing-alias
.
Closes pylint-dev/pylint#9220
v3.0.1
-
Fix crashes linting code using PEP 695 (Python 3.12) generic type syntax.
Closes pylint-dev/pylint#9098
v3.0.0
-
Add support for Python 3.12, including PEP 695 type parameter syntax.
Closes #2201
-
Remove support for Python 3.7.
Refs #2137
-
Use the global inference cache when inferring, even without an explicit
InferenceContext
. This is a significant performance improvement given how
often methods default toNone
for the context argument. (Lintingastroid
itself now takes ~5% less time on Python 3.12; other projects requiring more
complex inference calculations will see greater speedups.)Refs #529
-
Following a deprecation period starting in astroid 2.7.0, the
astroid.node_classes
andastroid.scoped_nodes
modules have been removed in favor ofastroid.nodes.node_classes
andastroid.nodes.scoped_nodes
.Closes #1072
-
Following a deprecation period starting in astroid 2.12.0, the
astroid.mixins
module
has been removed in favor ofastroid.nodes._base_nodes
(private).Refs #1633
-
Return all existing arguments when calling
Arguments.arguments()
. This also meansfind_argname
will now
use the whole list of arguments for its search.Closes #2213
-
Exclude class attributes from the
__members__
container of anEnum
class when they are
nodes.AnnAssign
nodes with no assigned value. -
Remove
@cached
and@cachedproperty
decorator (just use@cached_property
from the stdlib). -
Remove the
inference
module. Node inference methods are now in the module
defining the node, rather than being associated to the node afterward.Closes #679
-
Move
LookupMixIn
toastroid.nodes._base_nodes
and make it private. -
Remove the shims for
OperationError
,BinaryOperationError
, andUnaryOperationError
inexceptions
. They were moved toutil
in astroid 1.5.0. -
Move
safe_infer()
fromhelpers
toutil
. This avoids some circular imports. -
Reduce file system access in
ast_from_file()
. -
Reduce time to
import astroid
by delayingastroid_bootstrapping()
until
the first instantiation ofAstroidBuilder
.Closes #2161
-
Make
igetattr()
idempotent. This addresses some reports of varying results
when running pylint with--jobs
.Closes pylint-dev/pylint#4356
Refs #7 -
Fix incorrect cache keys for inference results, thereby correctly inferring types
for calls instantiating types dynamically.Closes #1828
Closes pylint-dev/pylint#7464
Closes pylint-dev/pylint#8074 -
Fix interrupted
InferenceContext
call chains, thereby addressing performance
problems when lintingsqlalchemy
.Closes pylint-dev/pylint#8150
-
nodes.FunctionDef
no longer inherits fromnodes.Lambda
.
This is a breaking change but considered a bug fix as the nodes did not share the same
API and were not interchangeable.We have tried to minimize the amount of breaking changes caused by this change
but some are unavoidable. -
infer_call_result
now shares the same interface across all implementations. Namely:def infer_call_result( self, caller: SuccessfulInferenceResult | None, context: InferenceContext | None = None, ) -> Iterator[InferenceResult]:
This is a breaking change for
nodes.FunctionDef
where previouslycaller
had a default of
None
. PassingNone
again will not create a behaviour change.
The breaking change allows us to better type and re-use the method withinastroid
. -
Improved signature of the
__init__
and__postinit__
methods of most nodes.
This includes makinglineno
,col_offset
,end_lineno
,end_col_offset
andparent
required arguments fornodes.NodeNG
and its subclasses.
For most other nodes, arguments of their__postinit__
methods have been made required to better
represent how they would normally be constructed by the standard libraryast
module.
The following nodes were changed or updated:nodes.AnnAssign
nodes.Arguments
nodes.Assign
nodes.AssignAttr
nodes.AssignName
nodes.Attribute
nodes.AugAssign
nodes.Await
nodes.BaseContainer
nodes.BinOp
nodes.Call
nodes.ClassDef
nodes.Compare
nodes.Comprehension
nodes.Decorators
nodes.Delete
nodes.DelAttr
nodes.DelName
nodes.Dict
nodes.DictComp
nodes.ExceptHandler
nodes.Expr
nodes.For
nodes.FunctionDef
nodes.GeneratorExp
nodes.If
nodes.IfExp
nodes.Keyword
nodes.Lambda
nodes.ListComp
nodes.Module
nodes.Name
nodes.NodeNG
nodes.Raise
nodes.Return
nodes.SetComp
nodes.Slice
nodes.Starred
objects.Super
, we also added thecall
parameter to its__init__
method.nodes.Subscript
nodes.UnaryOp
nodes.While
nodes.Yield
These changes involve breaking changes to their API but should be considered bug fixes. We
now make arguments required when they are instead of always providing defaults. -
nodes.If.self.is_orelse
has been removed as it was never set correctly and therefore
provided a false value. -
Remove dependency on
wrapt
. -
Remove dependency on
lazy_object_proxy
. This includes the removal
of the associatedlazy_import
,lazy_descriptor
andproxy_alias
utility functions. -
CallSite._unpack_args
andCallSite._unpack_keywords
now usesafe_infer()
for
better inference and fewer false positives.Closes pylint-dev/pylint#8544
-
Add
attr.Factory
to the recognized class attributes for classes decorated withattrs
.Closes pylint-dev/pylint#4341
-
infer_property()
now observes the same property-specific workaround asinfer_functiondef
.Refs #1490
-
Remove unused and / or deprecated constants:
astroid.bases.BOOL_SPECIAL_METHOD
astroid.bases.BUILTINS
astroid.const.BUILTINS
astroid.const.PY38_PLUS
astroid.const.Load
astroid.const.Store
astroid.const.Del
Refs #2141
-
frame()
raisesParentMissingError
andstatement()
raisesStatementMissing
for
missing parents regardless of the value of thefuture
argument (which gave this behavior
already).The
future
argument to each method is deprecated and will be removed in astroid 4.0.Refs #1217
-
Remove deprecated
Ellipsis
,ExtSlice
,Index
nodes.Refs #2152
-
Remove deprecated
is_sys_guard
andis_typing_guard
methods.Refs #2153
-
Remove deprecated
doc
attribute forModule
,ClassDef
, andFunctionDef
.
Use thedoc_node
attribute instead.Refs #2154
-
Add new
nodes.Try
to better match Python AST. Replaces theTryExcept
andTryFinally
nodes which have been removed. -
Publicize
NodeNG.repr_name()
to facilitate finding a node's nice name. -
Fix false positives for
no-member
andinvalid-name
when using the_name_
,_value_
and_ignore_
sunders in Enums.Closes pylint-dev/pylint#9015
v2.15.8
-
Fix a regression in 2.15.7 for
unsubscriptable-object
.Closes #2305
Closes pylint-dev/pylint#9069
v3.0.0b0
Pre-release for astroid 3.0.0, with API deprecation applied.
v2.15.7
-
Fix a crash when inferring a
typing.TypeVar
call.Closes pylint-dev/pylint#8802
-
Infer user-defined enum classes by checking if the class is a subtype of
enum.Enum
.Closes pylint-dev/pylint#8897
-
Fix inference of functions with
@functools.lru_cache
decorators without
parentheses.Closes pylint-dev/pylint#8868
-
Make
sys.argv
uninferable because it never is. (It's impossible to infer
the value it will have outside of static analysis where it's our own value.)
v3.0.0a9
Pre-release for astroid 3.0.0, with performance improvements, fixes for Python 3.12 compatibility, and an improvement to Arguments.arguments()
, among other changes.
See the full list of changes.