Skip to content

Stubgen giving error about self documenting expressions in f-strings #10791

Closed
@cquick01

Description

@cquick01

Bug Report

Hi, I am trying to run stubgen but am running into an error

Critical error during semantic analysis: path/to/script.py:140: error: f-string: self documenting expressions are only supported in Python 3.8 and greater

But, I'm running Python 3.9.6, and mypy 0.910 which should definitely support 3.8+ since mypy 0.800 added support for 3.9.

To Reproduce

Paths to binaries

(venv) $ which python
/home/cquick/test/venv/bin/python
(venv) $ which mypy
/home/cquick/test/venv/bin/mypy
(venv) $ which stubgen
/home/cquick/test/venv/bin/stubgen

Versions

(venv) $ python -V
Python 3.9.6

(venv) $ python -m pip install -U mypy
Requirement already satisfied: mypy in ./venv/lib/python3.9/site-packages (0.910)
Requirement already satisfied: typing-extensions>=3.7.4 in ./venv/lib/python3.9/site-packages (from mypy) (3.10.0.0)
Requirement already satisfied: toml in ./venv/lib/python3.9/site-packages (from mypy) (0.10.2)
Requirement already satisfied: mypy-extensions<0.5.0,>=0.4.3 in ./venv/lib/python3.9/site-packages (from mypy) (0.4.3)

(venv) $ mypy -V
mypy 0.910

Simple test script

(venv) $ cat test.py
#!/usr/bin/env python3

def foo(x):
    print(f"{x = }")

if __name__ == "__main__":
    foo(1)

Test script successfully prints self documenting expression

(venv) $ python test.py
x = 1

But running stubgen fails

(venv) $ stubgen test.py
Critical error during semantic analysis: test.py:4: error: f-string: self documenting expressions are only supported in Python 3.8 and greater

Expected Behavior

Stubgen would run successfully.

Actual Behavior

Stubgen produces Critical error during semantic analysis

Your Environment

  • Mypy version used: 0.910
  • MypyStubgen command-line flags: stubgen test.py
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.9.6
  • Operating system and version: Same behavior both on Ubuntu 18.04.5 LTS (WSL2) and with latest python:3-buster Docker images (currently 3.9.6) with mypy 0.910 installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions