diff mbox series

[meta-python,01/18] python3-astroid: Upgrade 4.3.4 -> 4.4.0

Message ID 20261201203145.3954930-1-leon.anavi@konsulko.com
State Under Review
Headers show
Series [meta-python,01/18] python3-astroid: Upgrade 4.3.4 -> 4.4.0 | expand

Commit Message

Leon Anavi Dec. 1, 2026, 8:31 p.m. UTC
Upgrade to release 4.4.0:

Breaking Changes

- Support for Python 3.10 was dropped, along with the PY311_PLUS
  constant and the typing-extensions runtime dependency. Python
  3.11 is now the minimum version.

New Features

- t-strings (TemplateStr) are now inferred: a t-string is inferred
  as an instance of string.templatelib.Template and an
  interpolation field as an instance of
  string.templatelib.Interpolation. Their members are reconstructed
  from the actual template contents, so Template.strings / values /
  interpolations and Interpolation.value / expression / conversion
  / format_spec infer to the same values as at runtime, including
  inside a called function, and adding two t-strings infers to the
  concatenated template. A Template or Interpolation built by
  calling the class directly is still a plain instance with
  uninferable members. The standard library defines those classes
  via type(t"..."), which is not statically inferable, so a brain
  plugin rebuilds the real classes from the live objects. as_string
  now also escapes literal braces and quotes in the constant parts
  of a t-string so the rendered code round-trips.

- Inference now narrows values through conditions joined by and and
  or. A variable tested by several constraints at once, as in if
  isinstance(apple, int) and apple != 3, keeps only the values
  satisfying every operand, and the or and negated forms are
  handled too. Inference stays conservative when an operand cannot
  be inferred or does not constrain the variable.

- When --prefer-stubs is enabled in Pylint, .pyi stub files are now
  loaded and used during inference, and compiled extensions with an
  adjacent stub use the stub instead of runtime introspection. Stub
  functions whose bodies contain only ..., pass, or a docstring
  infer the return type from the annotation.

- Inference now narrows values through the preceding operands of
  and and or. In x is not None and x, the last x no longer infers
  None. In x is None or x, the last x is only evaluated when x is
  None is false, so that condition is applied inverted. Constraints
  from several preceding operands, including nested boolean
  operations, are combined.

- Add a brain for numpy.dtypes, whose DType classes (StringDType,
  Float64DType, ...) NumPy attaches at import time, so they can now
  be inferred. Each class gets its own constructor rather than
  numpy.dtype's (obj, align, copy), so pylint no longer reports
  no-member on them nor no-value-for-parameter /
  unexpected-keyword-arg on calls such as
  StringDType(na_object=None).

- Inference now narrows values through conditions negated with not.
  not isinstance(x, int), not (x is None) and not (isinstance(x,
  int) and x == 3) used to constrain nothing; they now behave like
  the inverted condition in if statements, conditional expressions,
  comprehensions and boolean operations.

- Inference now narrows values after guard statements. After if x
  is None: return, x no longer infers None, and assert
  isinstance(x, int) keeps only the int values of x for the code
  after it. An if is a guard when its body ends with return, raise,
  continue or break. An assignment between the guard and the use is
  not narrowed, and neither is a function, lambda or class defined
  after the guard.

- Inference now narrows values after an if whose body assigns the
  name. After if x is None: x = [], x no longer infers the None it
  had before the if. This works for names and attributes, such as
  self.x or cls.x, with any condition that inference already
  narrows on.

- Inference now narrows values with callable(x) conditions. After
  if callable(x):, x no longer infers values that cannot be called,
  and after if not callable(x): it no longer infers values that
  can.

Bug Fixes

- Keep applying subsequent transforms when a transform returns
  None, preserving the current node instead of stopping the
  transform chain.

- Infer list augmented concatenation with a tuple as a list, rather
  than Uninferable.

- dataclass_transform() now always returns the transformed ClassDef
  node so subsequent Enum inference still populates __members__ on
  @dataclass(init=False) and custom-__init__ enum classes.

- Add support for NumPy 2.x, fixing false positives when analyzing
  code that uses NumPy 2.

- dataclasses.replace(obj, ...) is now inferred as an instance of
  obj's own class instead of being inferred through the stdlib body
  of replace(). That body resolves obj.__class__ through the
  metaclass chain, which fails when a base is a subscripted generic
  such as Base[T]: the call became Uninferable with the old-style
  Generic[T] syntax, and resolved to the wrong class with PEP 695
  class Base[T] syntax. The concrete caller type is now propagated
  correctly, including through Self-annotated method chains.

- Fix inference of callable instances stored as attributes,
  including attributes with a same-named member on the callable.
  Infer the result of calling the instance instead of looking up
  the attribute name on it again.

- modutils.get_source_file no longer returns a compiled module as
  if it were source. Bytecode (.pyc/.pyo) and binary extension
  modules (.so/.pyd/.dll) now fall through to the regular
  stub/source lookup, so a .pyi stub sitting next to a compiled
  module is found again instead of the compiled file being handed
  back and then parsed as source.

- Require a C extension to be located in the standard library
  before its standard library name allows it to be imported. A name
  such as colorsys was trusted on its own, so an extension of that
  name sitting next to the analysed sources was imported, and its
  module initialisation run, without being on
  extension-pkg-allow-list. Extensions shipped with the interpreter
  are unaffected.

- Do not infer a functional Enum whose class name is not a string.
  Such a definition is invalid at runtime and could expose a
  non-string class name to consumers.

- modutils.module_in_path no longer reports a module as living
  under a directory when its path only shares a leading name with
  that directory, such as a module in proj_extra matching the path
  proj. It now uses the same separator-aware containment check as
  _get_relative_base_path.

- as_string() no longer renders an f-string whose delimiter
  reappears unescaped in its body. Such an f-string terminated
  early and either failed to parse or reparsed to a different
  expression, which matters because brain_dataclasses and
  brain_namedtuple_enum reparse as_string() output.

- as_string() no longer raises ValueError on an integer constant
  too large to repr() (past sys.get_int_max_str_digits()); such
  integers are rendered as hex literals instead. This crashed the
  dataclass transform when a field was shadowed by a property
  returning e.g. 10  5000.

- The fallback __new__ of the object model, used when the real one
  cannot be found (instance.__new__, super().__new__(cls) under an
  uninferable ancestor, or the __new__ of a C type outside
  builtins), now has the signature (cls, *args, kwargs) instead of
  (self, cls). Since __new__ takes the class explicitly, the old
  signature reported the class argument as missing and any other
  argument as unexpected.

- Fix a crash when inferring a super() call inside a function that
  is decorated with @classmethod but is not defined inside a class.

- AsStringVisitor no longer lets a docstring break out of the
  triple-quoted literal it is rendered into. A docstring value
  containing """, ending in a quote, or holding a NUL byte
  previously closed the literal early or, through the DOC_NEWLINE
  sentinel, injected extra lines into as_string() output, which the
  dataclass and namedtuple brains reparse. Such values now fall
  back to repr so the output round-trips.

- Infer a str/bytes old-style % interpolation without crashing when
  a %c conversion receives an out-of-range code point, such as "%c"
  % 0x110000 or b"%c" % 256. The evaluation now catches
  OverflowError and yields Uninferable, matching the other invalid
  interpolations.

- Infer an enum member whose integer value is past the int-to-str
  conversion limit, such as A = 0xff... (a large hex literal the
  tokenizer accepts).

- Fix an AttributeError crash when inferring a typing.NamedTuple
  subclass or an enum.Enum whose body contains an assignment target
  that is not a plain name, such as the annotation a.b: str or the
  chained assignment x = a.b = 1. Such targets do not name a field
  or member and are now skipped.

- brain_gi only imports gi for a bare require_version(...) call
  when the name actually resolves to gi, no longer for an unrelated
  function of that name.

- The numpy brain no longer imports numpy to find out its version
  but reads from the installed package metadata instead.

- Fix an IndexError crash when inferring a functional enum.Enum
  call whose member list contains an empty tuple, such as
  enum.Enum("E", [()]). Such an invalid member now degrades to
  Uninferable instead of raising.

- Fix TypeError in FunctionDef.infer_call_result for a function
  named with_metaclass when the caller is a function, such as the
  decorator's parent while inferring FunctionDef.type.

- A class attribute is now inferred with the values assigned to it
  through the class in the module that defines it, as in cls.attr =
  value in a class method or Klass.attr = value, along with the
  value set in the class body. Only the latter used to be inferred,
  so pylint reported unsubscriptable-object,
  unsupported-membership-test and similar errors on lazily
  initialized class attributes such as cache = None. A value
  assigned to an attribute of a parent class also no longer leaks
  into a subclass that assigns the same attribute in the same
  scope.

- Fix an AssertionError when inferring a namedtuple, or a class
  derived from typing.NamedTuple, if collections.namedtuple itself
  cannot be inferred. The namedtuple is now built as if
  rename=False.

- Fix TypeError in ClassDef.ancestors() when typing.Tuple or
  typing.Callable is first inferred with an exhausted inference
  context. The synthesized class was built with an uninferable base
  and reused for every later inference.

- Fix a crash when inferring an attribute that resolves to a method
  proxying something other than a function.

- Add a name to Slice nodes, giving "slice" like other inferred
  builtin values (Const, List, Dict...) give the name of their
  type. A slice object used as a class base, metaclass, exception
  or super() argument no longer crashes code that reads the name of
  an inferred value.

- Infer the name bound by a type statement as a
  typing.TypeAliasType instance instead of the aliased value, so
  __value__ and the other alias attributes are found on it.

- Fix an uncaught TypeError when inferring a starred name nested in
  a for target, such as for a, (b, *c) in ..., over an element the
  inference cannot see into.

- Do not cache inference results that were truncated by the
  inference budget. Caching them made inference results depend on
  the order in which modules were analysed.

- Prevent a TypeError in infer_typing_alias when _alias() is called
  with a non-integer constant second argument.

- Source files are now closed when reading fails during module
  building.

- FunctionDef.getattr() and Lambda.getattr() no longer add the
  special attribute to instance_attrs when an attribute such as
  __name__ is both assigned on the function and a special
  attribute. The stored list used to grow by one on every lookup.
  ClassDef.repr_tree(ast_state=True) no longer raises
  AttributeError.

- Fix a crash when inferring len() on an instance whose __len__ is
  not callable, such as a module. The call is now uninferable
  instead.

- Fix AttributeError when calling qname() on a generator expression
  or a list, set or dict comprehension. They are now named
  <genexpr>, <listcomp>, <setcomp> and <dictcomp>, like <lambda>,
  which also shows in their repr.

- Stop inferring a __get__ attribute on generators, which are not
  descriptors. Accessing it is now reported as no-member, like the
  AttributeError at runtime, instead of crashing attribute
  inference.

- Fix AttributeError when inferring the call result of a subclass
  of type without a caller.

- ClassDef.has_dynamic_getattr() now always returns a bool. It
  returned Uninferable when the __getattr__ of a metaclass could
  not be inferred.

- modpath_from_file() no longer raises ImportError for a module
  inside a namespace package that also exists in site-packages: the
  namespace package is now looked up from the directory the module
  is resolved from.

- Fixed isinstance() and issubclass() inference constraint when the
  classinfo is a PEP 604 union, e.g. isinstance(x, int | str).

- Apply the !s, !r and !a conversions when inferring f-strings, so
  f'{"a"!r}' is inferred as "'a'" instead of 'a'.

- Infer names bound by an import in an enum class body as enum
  members, like assigned names, instead of as the plain imported
  object.

- Do not treat values wrapped in enum.nonmember() as members of the
  enum. They were listed in __members__, so pylint reported
  invalid-enum-extension when such a class was extended, for
  example on any Django 6 models.Choices subclass.

- Fix a hang when inferring a class whose __bool__ reads attributes
  that are narrowed by a truthiness guard (if self.left:). The
  truthiness constraint now passes the inference context to
  bool_value(), so the recursion guard applies.

- Only treat a function as a property because of its decorator's
  name, like @lazy or @reify, when the function is defined in a
  class body. A function decorated this way elsewhere stays a
  function, so it is no longer inferred as a property object that
  is not callable.

- typing.NamedTuple is now inferred as a tuple subclass with
  _asdict, _replace, _fields, _make and _field_defaults, as
  typeshed declares it. self in a method of a typing.NamedTuple
  subclass finds that API and the tuple methods such as count and
  index through it, so pylint no longer reports no-member,
  unsubscriptable-object or not-an-iterable on self there.

- The ctypes brain now gives the value argument of c_int, c_char,
  c_double and the other simple types the same default as at
  runtime (0, 0.0, b"\x00", "\x00" or False). apple = c_int() no
  longer makes pylint emit no-value-for-parameter on interpreters
  where _ctypes is a built-in module, such as the uv and
  python-build-standalone builds.

- Fix a false positive for functools.partial objects stored as
  class attributes: before Python 3.14, accessing one through an
  instance does not bind self, and astroid no longer infers a bound
  method for it.

Other Changes

- A RecursionError raised while parsing a file is now enriched with
  a note naming the file that could not be parsed, and advising to
  raise the recursion limit (from pylint: --init-hook='import sys;
  sys.setrecursionlimit(2000)').

Internal Changes

- Remove register_builtin_transform from
  astroid.brain.brain_builtin_inference. It was only meant for
  astroid's own builtin brain, which now declares its inference
  functions in a static dispatch table.

- The changelog is now assembled by towncrier from news fragments
  in doc/whatsnew/fragments/, like in pylint. Add a <issue>.<type>
  fragment there instead of editing a changelog file.

Performance Improvements

- Collapse the 19 builtin inference transforms into a single
  dispatcher transform on nodes.Call. The transform visitor
  previously ran 19 predicates per Call node, each repeating the
  same isinstance checks; the dispatcher does them once and routes
  by name via a dict.

Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
---
 .../{python3-astroid_4.3.4.bb => python3-astroid_4.4.0.bb}      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 rename meta-python/recipes-devtools/python/{python3-astroid_4.3.4.bb => python3-astroid_4.4.0.bb} (89%)
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-astroid_4.3.4.bb b/meta-python/recipes-devtools/python/python3-astroid_4.4.0.bb
similarity index 89%
rename from meta-python/recipes-devtools/python/python3-astroid_4.3.4.bb
rename to meta-python/recipes-devtools/python/python3-astroid_4.4.0.bb
index fd4c3e40e4..47f787f56c 100644
--- a/meta-python/recipes-devtools/python/python3-astroid_4.3.4.bb
+++ b/meta-python/recipes-devtools/python/python3-astroid_4.4.0.bb
@@ -4,7 +4,7 @@  SECTION = "devel/python"
 LICENSE = "LGPL-2.1-only"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=a70cf540abf41acb644ac3b621b2fad1"
 
-SRC_URI[sha256sum] = "d515a105722b72098bbe82d430d65e635f742b6cbac3bdfaf8b7c188b87c5e39"
+SRC_URI[sha256sum] = "71209faedbcdf7e1dac69e371fcc243bc17fbed08c605e6578bb706bb8408b6a"
 
 inherit pypi python_setuptools_build_meta