KEMBAR78
False positive [str-format] for Sequence[] · Issue #7764 · python/mypy · GitHub
Skip to content

False positive [str-format] for Sequence[] #7764

@jolaf

Description

@jolaf

The following code:

from typing import Sequence

t: Sequence[str] = ('A', 'B')
print("%s %s" % t)

produces the following output:

$ python3 Test.py 
A B
$ mypy Test.py 
Test.py:4: error: Not enough arguments for format string
Found 1 error in 1 file (checked 1 source file)
$ mypy --version
mypy 0.740
$ python3 --version
Python 3.6.8

I understand that this case cannot be fully resolved, but my concern is about the error message, which is misleading.

Probably it should be something like Can't determine if the number of arguments for format string is correct instead.

Or maybe no error should be issued at all to avoid false positives.

Or maybe an additional configuration option may be introduced to regulate whether an error should be issued in cases like this one.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions