pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.26k stars 1.12k forks source link

RecursionError when analyzing sqlalchemy's code #9899

Closed alessandro-fiorino closed 1 month ago

alessandro-fiorino commented 1 month ago

It crashes on every file, I pust just a little one as exmaple When parsing the following a.py:

# -*- coding: utf-8 -*-
from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, Integer, String

Base = declarative_base()

class Item(Base):
    __tablename__ = "items"
    id = Column(Integer, primary_key=True, index=True)
    name = Column(String, index=True)
    description = Column(String, index=True)

Command used

pylint a.py

Pylint output

pylint crashed with a ``AstroidError`` and with the following stacktrace: ```python Traceback (most recent call last): File "C:\Python311\Lib\site-packages\pylint\lint\pylinter.py", line 787, in _lint_file check_astroid_module(module) File "C:\Python311\Lib\site-packages\pylint\lint\pylinter.py", line 1016, in check_astroid_module retval = self._check_astroid_module( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\pylint\lint\pylinter.py", line 1068, in _check_astroid_module walker.walk(node) File "C:\Python311\Lib\site-packages\pylint\utils\ast_walker.py", line 94, in walk self.walk(child) File "C:\Python311\Lib\site-packages\pylint\utils\ast_walker.py", line 91, in walk callback(astroid) File "C:\Python311\Lib\site-packages\pylint_odoo\checkers\odoo_addons.py", line 1274, in visit_importfrom self.check_odoo_relative_import(node) File "C:\Python311\Lib\site-packages\pylint_odoo\checkers\odoo_addons.py", line 1523, in check_odoo_relative_import manifest_path = misc.walk_up(node_dirpath, tuple(misc.MANIFEST_FILES), misc.top_path(node_dirpath)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\pylint_odoo\misc.py", line 102, in walk_up return walk_up(os.path.dirname(path), filenames, top) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\pylint_odoo\misc.py", line 102, in walk_up return walk_up(os.path.dirname(path), filenames, top) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\pylint_odoo\misc.py", line 102, in walk_up return walk_up(os.path.dirname(path), filenames, top) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [Previous line repeated 487 more times] File "C:\Python311\Lib\site-packages\pylint_odoo\misc.py", line 99, in walk_up path_filename = os.path.join(path, filename) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 120, in join RecursionError: maximum recursion depth exceeded The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Python311\Lib\site-packages\pylint\lint\pylinter.py", line 751, in _lint_files self._lint_file(fileitem, module, check_astroid_module) File "C:\Python311\Lib\site-packages\pylint\lint\pylinter.py", line 789, in _lint_file raise astroid.AstroidError from e astroid.exceptions.AstroidError ```

Expected behavior

No crash.

Pylint version

pylint 3.1.1
astroid 3.1.0
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]

OS / Environment

win32 (Windows)

jacobtylerwalls commented 1 month ago

Please reopen if you can reproduce with the latest.