See #9221 (closed)
Bug Report
Upgrading to mypy 2.3.0 introduced the bug.
Very strangely, reverting to mypy 2.2.0 did not change the behavior described next.
Also, the behavior seems independent of which of Leo's GitHub branches is active.
To Reproduce
cd c:\Repos\leo-editor
python -m leo.scripts.mypy_leo leo
The following mypy-leo.cmd script seems to produce the same results:
@echo off
cd c:\Repos\leo-editor
python -m leo.scripts.mypy_leo
Actual Behavior
mypy is now complaining about virtually every string slice within Leo. For example:
def findDirective(self, directive_name: str) -> bool:
if directive_name.startswith('@'):
directive_name = directive_name[1:]
produces this complaint:
leo\core\leoNodes.py:754: error: Invalid index type "slice[int, None, None]" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex]" [index]
Expected Behavior
No complaints!
Your Environment
- Mypy version used: mypy 2.3.0 (compiled: yes)
- Mypy command-line flags: None.
leo.scripts.mypy_leo may set flags, but the results don't seem to change.
- Mypy configuration options from
mypy.ini: See next section
- Python version used: Python 3.14.0
.mypy.ini
# Config file for mypy
# Note: Do not put comments after settings.
[mypy]
python_version = 3.14
cache_dir = mypy_cache
# Defaults for all files.
check_untyped_defs = True
follow_imports = skip
ignore_missing_imports = True
incremental = False
show_error_codes = True
strict_optional = False
disable_error_code=attr-defined
# For v0.931, per https://github.com/python/mypy/issues/11936
exclude =
# The first line must *not* start with |.
# Thereafter, each line *must* start with |.
# No trailing '|' on last entry!
# Directories...
doc/|dist/|editpane/|examples/|extensions/|external/|modes/|obsolete/|scripts/|themes/|unittests/|www/|
# Special plugins...
|freewin.py|scriptFile.py|beautify_node.py|viewrendered3|
# Experimental plugins...
|leo_pdf|leo_to_rtf|mnplugins|mod_speedups|settings_finder|stickynotes_plus|
# qt_main.py is generated automatically, so it's pointless to add annotations.
|qt_main
# #4766: more specific descriptions override less specific.
[mypy-leo.core.leoApp,leo.core.leoConfig,leo.core.leoNodes,leo.core.leoGlobals,leo.core.leoCommands]
strict_optional = True
Summary
This is an extremely strange bug.
Happily, adding disable_error_code=attr-defined,index to .mypy.ini calms mypy down.
Any suggestions would be greatly appreciated!
See #9221 (closed)
Bug Report
Upgrading to mypy 2.3.0 introduced the bug.
Very strangely, reverting to mypy 2.2.0 did not change the behavior described next.
Also, the behavior seems independent of which of Leo's GitHub branches is active.
To Reproduce
The following mypy-leo.cmd script seems to produce the same results:
Actual Behavior
mypy is now complaining about virtually every string slice within Leo. For example:
produces this complaint:
leo\core\leoNodes.py:754: error: Invalid index type "slice[int, None, None]" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex]" [index]Expected Behavior
No complaints!
Your Environment
leo.scripts.mypy_leo may set flags, but the results don't seem to change.
mypy.ini: See next section.mypy.ini
Summary
This is an extremely strange bug.
Happily, adding
disable_error_code=attr-defined,indexto .mypy.ini calms mypy down.Any suggestions would be greatly appreciated!