mypy strict: error: Module "streamlit" does not explicitly export attribute "experimental_dialog" [attr-defined] (among others) #8712
Labels
feature:st.dialog
priority:P4
status:confirmed
Bug has been confirmed by the Streamlit team
status:in-progress
We're on it!
type:bug
Something isn't working
Checklist
Summary
Trying to use the experimental_dialog decorator at all gives an error in typechecking in mypy strict mode. (strict mode turns on no_implicit_reexport). Also in pyright as well.
The mypy error is
error: Module "streamlit" does not explicitly export attribute "experimental_dialog" [attr-defined]
. The pyright error iserror: "experimental_dialog" is not exported from module "streamlit" (reportPrivateImportUsage)
After much staring at https://github.com/streamlit/streamlit/blob/1.34.0/lib/streamlit/__init__.py#L77 , I realized the answer is actually simple: a reexport is not explicit unless you
as
the variable to the same name. As mypy documentation says https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-no-implicit-reexport:Therefore, exports like
dialog_decorator as experimental_dialog
are a problem, and do not serve their intended purpose.So, you cannot rename the variable in the reexport and have it still work. But I'm pretty sure you can still put
experimental_dialog = dialog_decorator
in the source file, though, and then have your reexport line beif you want.
P.S.: The
Modules that the user should have access to. These are imported with "as" syntax pass mypy checking with implicit_reexport disabled.
" comment block, seems to have a typo, by the way, and also doesn't seem very useful as currently written, and also possibly is misplaced.Reproducible Code Example
Steps To Reproduce
$ mypy --strict example.py
example.py:3: error: Module "streamlit" does not explicitly export attribute "experimental_dialog" [attr-defined]
$ mypy example.py
Success: no issues found in 1 source file
Expected Behavior
No response
Current Behavior
No response
Is this a regression?
Debug info
Additional Information
No response
The text was updated successfully, but these errors were encountered: