Skip to content

Crash PylintF0002:astroid-error Fatal Crash on Start of Pylint in VSCode #10353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jhenderson-moshipco opened this issue Apr 24, 2025 · 2 comments
Labels
Crash 💥 A bug that makes pylint crash Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine

Comments

@jhenderson-moshipco
Copy link

jhenderson-moshipco commented Apr 24, 2025

Bug description

When parsing the following file.py:

Can't share code. Stacktrace gives the source of the error.
The crash shows a key error in our vars.py file which is establishing constant variables from our .env file.
2 Developers working on the same code, 1 experiences the fatal crash and the other does not. We have confirmed same versioning of VSCode, Astroid, Pylint, and the same .env file. Code repository is also in the same branch and no differences in current code between the two devs.

Command used

pylint file.py

Pylint output

pylint crashed with a ``AstroidError`` and with the following stacktrace:

Expected behavior

No crash.

Configuration

[tool.pylint]
function-naming-style="camelCase"
method-naming-style="camelCase"
typevar-rgx="_?[A-Z][a-zA-Z]*$"
include-naming-hint="y"
notes-rgx='(FIXME|XXX|TODO)(?!.*\(#\d+\))'
notes='FIXME'
ignore-paths=['database/schema.py']
max-line-length=120
disable='no-member,no-else-return,too-few-public-methods,broad-exception-caught,use-implicit-booleaness-not-comparison,unspecified-encoding'

Command used

VSCode Pylint Extension

Pylint output

Traceback (most recent call last):
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/checkers/imports.py", line 1014, in _get_imported_module
    return importnode.do_import_module(modname)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/nodes/_base_nodes.py", line 168, in do_import_module
    return mymodule.import_module(
           ~~~~~~~~~~~~~~~~~~~~~~^
        modname,
        ^^^^^^^^
    ...<2 lines>...
        use_cache=use_cache,
        ^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/nodes/scoped_nodes/scoped_nodes.py", line 462, in import_module
    return AstroidManager().ast_from_module_name(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        absmodname, use_cache=use_cache
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/manager.py", line 228, in ast_from_module_name
    found_spec = self.file_from_module_name(modname, context_file)
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/manager.py", line 321, in file_from_module_name
    value = file_info_from_modpath(
        modname.split("."), context_file=contextfile
    )
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/modutils.py", line 376, in file_info_from_modpath
    return _spec_from_modpath(modpath, path, context)
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/modutils.py", line 631, in _spec_from_modpath
    found_spec = spec.find_spec(modpath, path)
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/interpreter/_import/spec.py", line 484, in find_spec
    return _find_spec(tuple(modpath), tuple(path) if path else None)
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/interpreter/_import/spec.py", line 500, in _find_spec
    finder, spec = _find_spec_with_path(
                   ~~~~~~~~~~~~~~~~~~~~^
        _path, modname, module_parts, processed, submodule_path or path
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/interpreter/_import/spec.py", line 420, in _find_spec_with_path
    spec = finder_instance.find_module(
        modname, module_parts, processed, submodule_path
    )
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/astroid/interpreter/_import/spec.py", line 180, in find_module
    spec = importlib.util.find_spec(".".join((*processed, modname)))
  File "<frozen importlib.util>", line 91, in find_spec
  File "/Users/jessehenderson/Documents/label-genius/labelgenius-api/graph/__init__.py", line 3, in <module>
    from .mutation import Mutation
  File "/Users/jessehenderson/Documents/label-genius/labelgenius-api/graph/mutation.py", line 13, in <module>
    from graph.context import GqlContext
  File "/Users/jessehenderson/Documents/label-genius/labelgenius-api/graph/context.py", line 10, in <module>
    from graph.loaders.adhoc import AdHocLoaders, AdHocWorkerLoaders
  File "/Users/jessehenderson/Documents/label-genius/labelgenius-api/graph/loaders/adhoc.py", line 15, in <module>
    from graph.enums.carrier import CARRIERS_BY_ID, CarrierCode
  File "/Users/jessehenderson/Documents/label-genius/labelgenius-api/graph/enums/__init__.py", line 4, in <module>
    from .carrier import CarrierCode
  File "/Users/jessehenderson/Documents/label-genius/labelgenius-api/graph/enums/carrier.py", line 5, in <module>
    from vars import CARRIER_IDS
  File "/Users/jessehenderson/Documents/label-genius/labelgenius-api/vars.py", line 16, in <module>
    ENVIRONMENT: Literal["DEV", "PROD", "TEST"] = environ["ENVIRONMENT"]  # type: ignore - narrowing
                                                  ~~~~~~~^^^^^^^^^^^^^^^
  File "<frozen os>", line 716, in __getitem__
KeyError: 'ENVIRONMENT'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/lint/pylinter.py", line 788, in _lint_file
    check_astroid_module(module)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/lint/pylinter.py", line 1020, in check_astroid_module
    retval = self._check_astroid_module(
        ast_node, walker, rawcheckers, tokencheckers
    )
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/lint/pylinter.py", line 1072, in _check_astroid_module
    walker.walk(node)
    ~~~~~~~~~~~^^^^^^
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/utils/ast_walker.py", line 90, in walk
    self.walk(child)
    ~~~~~~~~~^^^^^^^
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/utils/ast_walker.py", line 87, in walk
    callback(astroid)
    ~~~~~~~~^^^^^^^^^
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/checkers/imports.py", line 557, in visit_importfrom
    imported_module = self._get_imported_module(node, basename)
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/checkers/imports.py", line 1039, in _get_imported_module
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/lint/pylinter.py", line 752, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jessehenderson/.vscode/extensions/ms-python.pylint-2025.2.0/bundled/libs/pylint/lint/pylinter.py", line 790, in _lint_file
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError

Expected behavior

No Crash. Not sure if this should even attempt to read .env variables.

Pylint version

pylint 3.3.4
astroid 3.3.8
Python 3.13.2 (main, Feb  4 2025, 14:51:09) [Clang 16.0.0 (clang-1600.0.26.6)]

OS / Environment

Darwin Kernel Version 24.3.0

Additional dependencies

#
# This file is autogenerated by pip-compile with Python 3.13
# by the following command:
#
#    pip-compile --output-file=requirements.txt
#
aiofiles==24.1.0
    # via cloud-sql-python-connector
aiohappyeyeballs==2.6.1
    # via aiohttp
aiohttp==3.11.17
    # via
    #   -r requirements.in
    #   cloud-sql-python-connector
aiolimiter==1.2.1
    # via -r requirements.in
aiosignal==1.3.2
    # via aiohttp
aiosmtplib==4.0.0
    # via -r requirements.in
annotated-types==0.7.0
    # via pydantic
anyio==4.9.0
    # via
    #   httpx
    #   starlette
asn1crypto==1.5.1
    # via scramp
astroid==3.3.9
    # via pylint
asyncpg==0.30.0
    # via -r requirements.in
attrs==25.3.0
    # via aiohttp
black==25.1.0
    # via -r requirements.in
cachetools==5.5.2
    # via google-auth
certifi==2025.1.31
    # via
    #   httpcore
    #   httpx
    #   requests
cffi==1.17.1
    # via cryptography
charset-normalizer==3.4.1
    # via requests
click==8.1.8
    # via
    #   black
    #   typer
    #   uvicorn
cloud-sql-python-connector==1.18.1
    # via -r requirements.in
coverage[toml]==7.8.0
    # via
    #   -r requirements.in
    #   pytest-cov
cryptography==44.0.2
    # via
    #   cloud-sql-python-connector
    #   types-pyopenssl
    #   types-redis
defusedxml==0.7.1
    # via fpdf2
dill==0.4.0
    # via pylint
dnspython==2.7.0
    # via
    #   cloud-sql-python-connector
    #   email-validator
email-validator==2.2.0
    # via pydantic
fastapi==0.115.12
    # via
    #   -r requirements.in
    #   fastapi-versioning
fastapi-versioning==0.10.0
    # via -r requirements.in
fonttools==4.57.0
    # via fpdf2
fpdf2==2.8.2
    # via -r requirements.in
frozenlist==1.6.0
    # via
    #   aiohttp
    #   aiosignal
google-api-core==2.24.2
    # via
    #   google-cloud-core
    #   google-cloud-storage
google-auth==2.39.0
    # via
    #   cloud-sql-python-connector
    #   google-api-core
    #   google-cloud-core
    #   google-cloud-storage
google-cloud-core==2.4.3
    # via google-cloud-storage
google-cloud-storage==3.1.0
    # via -r requirements.in
google-crc32c==1.7.1
    # via
    #   google-cloud-storage
    #   google-resumable-media
google-resumable-media==2.7.2
    # via google-cloud-storage
googleapis-common-protos==1.70.0
    # via google-api-core
graphql-core==3.2.6
    # via strawberry-graphql
greenlet==3.2.0
    # via
    #   -r requirements.in
    #   sqlalchemy
h11==0.14.0
    # via
    #   httpcore
    #   uvicorn
holidays==0.70
    # via -r requirements.in
httpcore==1.0.8
    # via httpx
httpx==0.28.1
    # via -r requirements.in
idna==3.10
    # via
    #   anyio
    #   email-validator
    #   httpx
    #   requests
    #   yarl
inflect==7.5.0
    # via sqlacodegen
iniconfig==2.1.0
    # via pytest
isort==6.0.1
    # via pylint
jinja2==3.1.6
    # via -r requirements.in
libcst==1.7.0
    # via strawberry-graphql
markdown-it-py==3.0.0
    # via rich
markupsafe==3.0.2
    # via jinja2
mccabe==0.7.0
    # via pylint
mdurl==0.1.2
    # via markdown-it-py
mirakuru==2.6.0
    # via
    #   pytest-postgresql
    #   pytest-redis
more-itertools==10.6.0
    # via inflect
multidict==6.4.3
    # via
    #   aiohttp
    #   yarl
mypy-extensions==1.0.0
    # via black
nulltype==2.3.1
    # via plaid-python
numpy==2.2.5
    # via -r requirements.in
packaging==25.0
    # via
    #   black
    #   pytest
    #   pytest-postgresql
    #   strawberry-graphql
pathspec==0.12.1
    # via black
pg8000==1.31.2
    # via -r requirements.in
pillow==11.2.1
    # via
    #   -r requirements.in
    #   fpdf2
    #   zpl
plaid-python==29.1.0
    # via -r requirements.in
platformdirs==4.3.7
    # via
    #   black
    #   pylint
pluggy==1.5.0
    # via pytest
port-for==0.7.4
    # via
    #   pytest-postgresql
    #   pytest-redis
propcache==0.3.1
    # via
    #   aiohttp
    #   yarl
proto-plus==1.26.1
    # via google-api-core
protobuf==6.30.2
    # via
    #   google-api-core
    #   googleapis-common-protos
    #   proto-plus
psutil==7.0.0
    # via mirakuru
psycopg==3.2.6
    # via pytest-postgresql
pyasn1==0.6.1
    # via
    #   pyasn1-modules
    #   rsa
pyasn1-modules==0.4.2
    # via google-auth
pycparser==2.22
    # via cffi
pydantic[email]==2.11.3
    # via
    #   -r requirements.in
    #   fastapi
pydantic-core==2.33.1
    # via pydantic
pygments==2.19.1
    # via
    #   rich
    #   strawberry-graphql
pyjwt==2.10.1
    # via -r requirements.in
pylint==3.3.6
    # via -r requirements.in
pyotp==2.9.0
    # via -r requirements.in
pytest==8.3.5
    # via
    #   -r requirements.in
    #   pytest-asyncio
    #   pytest-cov
    #   pytest-mock
    #   pytest-postgresql
    #   pytest-redis
    #   pytest-snapshot
    #   pytest-socket
pytest-asyncio==0.26.0
    # via -r requirements.in
pytest-cov==6.1.1
    # via -r requirements.in
pytest-mock==3.14.0
    # via -r requirements.in
pytest-postgresql==7.0.1
    # via -r requirements.in
pytest-redis==3.1.3
    # via -r requirements.in
pytest-snapshot==0.9.0
    # via -r requirements.in
pytest-socket==0.7.0
    # via -r requirements.in
python-dateutil==2.9.0.post0
    # via
    #   holidays
    #   pg8000
    #   plaid-python
    #   strawberry-graphql
python-multipart==0.0.20
    # via strawberry-graphql
pytz==2025.2
    # via -r requirements.in
pyyaml==6.0.2
    # via libcst
redis==5.2.1
    # via
    #   -r requirements.in
    #   pytest-redis
requests==2.32.3
    # via
    #   -r requirements.in
    #   cloud-sql-python-connector
    #   google-api-core
    #   google-cloud-storage
    #   stripe
rich==14.0.0
    # via
    #   strawberry-graphql
    #   typer
rsa==4.9.1
    # via google-auth
scramp==1.4.5
    # via pg8000
shellingham==1.5.4
    # via typer
six==1.17.0
    # via python-dateutil
sniffio==1.3.1
    # via anyio
sqlacodegen==3.0.0
    # via -r requirements.in
sqlalchemy==2.0.40
    # via
    #   -r requirements.in
    #   sqlacodegen
starlette==0.46.2
    # via
    #   fastapi
    #   fastapi-versioning
    #   strawberry-graphql
strawberry-graphql[debug-server]==0.266.0
    # via -r requirements.in
stripe==12.0.0
    # via -r requirements.in
tomlkit==0.13.2
    # via pylint
typeguard==4.4.2
    # via inflect
typer==0.15.2
    # via strawberry-graphql
types-cffi==1.17.0.20250326
    # via types-pyopenssl
types-pyopenssl==24.1.0.20240722
    # via types-redis
types-redis==4.6.0.20241004
    # via -r requirements.in
types-setuptools==78.1.0.20250329
    # via types-cffi
typing-extensions==4.13.2
    # via
    #   fastapi
    #   pydantic
    #   pydantic-core
    #   sqlalchemy
    #   strawberry-graphql
    #   stripe
    #   typeguard
    #   typer
    #   typing-inspection
typing-inspection==0.4.0
    # via pydantic
urllib3==2.4.0
    # via
    #   -r requirements.in
    #   plaid-python
    #   requests
uvicorn==0.34.2
    # via
    #   -r requirements.in
    #   strawberry-graphql
yarl==1.20.0
    # via aiohttp
zpl==0.1.11
    # via -r requirements.in

# The following packages are considered to be unsafe in a requirements file:
# setuptools
@jhenderson-moshipco jhenderson-moshipco added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 24, 2025
@Pierre-Sassoulas Pierre-Sassoulas added Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine Crash 💥 A bug that makes pylint crash and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 24, 2025
@jhenderson-moshipco
Copy link
Author

Also another thing to note, this crashes on some files but not on others in the same folder path.

@jhenderson-moshipco
Copy link
Author

Reinstall of VSCode Fixed it. I had some other strange occurrences with my virtual environment vanishing from VSCode also so I decided to reinstall the entire app and all extensions. This seems to have fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine
Projects
None yet
Development

No branches or pull requests

2 participants