-
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
AstroidRelated to astroidRelated to astroidBlocker 🙅Blocks the next releaseBlocks the next releasepython 3.10
Milestone
Description
Bug description
Home Assistant dropped Python 3.9 this week. While upgrading all runtime annotations to the new union syntax, I discovered some issues with pylint. It seems astroid doesn't know how to handle these.
# pylint: disable=missing-docstring,too-few-public-methods,line-too-long,useless-suppression from __future__ import annotations from typing import Generic, TypeVar T = TypeVar("T") class Coordinator(Generic[T]): def __init__(self, update_interval=None) -> None: self.update_interval = update_interval class Child(Coordinator[int | str]): # <-- 'int | str' here seems to be the issue def __init__(self) -> None: Coordinator.__init__(self, update_interval=2) # non-parent-init-called def _async_update_data(self): assert self.update_interval # access-member-before-definition self.update_interval = 1 # attribute-defined-outside-initConfiguration
[MAIN] load-plugins= pylint.extensions.code_style, pylint.extensions.typing, py-version=3.10 [TYPING] runtime-typing=noCommand used
pylint test.pyPylint output
test.py:16:8: W0233: __init__ method from a non direct base class 'Coordinator' is called (non-parent-init-called) test.py:19:15: E0203: Access to member 'update_interval' before its definition line 20 (access-member-before-definition) test.py:20:8: W0201: Attribute 'update_interval' defined outside __init__ (attribute-defined-outside-init)Expected behavior
No errors
Pylint version
pylint 2.16.0b1 astroid 2.14.0-dev0 Python 3.11.1OS / Environment
No response
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
AstroidRelated to astroidRelated to astroidBlocker 🙅Blocks the next releaseBlocks the next releasepython 3.10