Skip to content

[stubtest] Type re-export creates duplicated error with invalid line number #15023

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

Open
sobolevn opened this issue Apr 9, 2023 · 1 comment
Labels
bug mypy got something wrong topic-stubtest

Comments

@sobolevn
Copy link
Member

sobolevn commented Apr 9, 2023

In this issue we can clearly see a problem: python/typeshed#10022

Error message:

 error: bs4.Tag.decode is inconsistent, stub does not have argument "iterator"
Stub: in file /home/runner/work/typeshed/typeshed/stubs/beautifulsoup4/bs4/__init__.pyi:301
def (self: bs4.element.Tag, indent_level: Union[builtins.int, None] =, eventual_encoding: builtins.str =, formatter: Union[builtins.str, bs4.formatter.Formatter] =) -> builtins.str
Runtime: in file /tmp/tmpn18q88e9/lib/python3.10/site-packages/bs4/element.py:1689
def (self, indent_level=None, eventual_encoding='utf-8', formatter='minimal', iterator=None)

error: bs4.element.Tag.decode is inconsistent, stub does not have argument "iterator"
Stub: in file /home/runner/work/typeshed/typeshed/stubs/beautifulsoup4/bs4/element.pyi:301
def (self: bs4.element.Tag, indent_level: Union[builtins.int, None] =, eventual_encoding: builtins.str =, formatter: Union[builtins.str, bs4.formatter.Formatter] =) -> builtins.str
Runtime: in file /tmp/tmpn18q88e9/lib/python3.10/site-packages/bs4/element.py:1689
def (self, indent_level=None, eventual_encoding='utf-8', formatter='minimal', iterator=None)

Why is it problematic?

  1. It is a duplicate (I think we can live with it, because change it is not trivial)
  2. Notice that __init__.py error has the same line number as the original, ideally it should have this line number: https://github.com/python/typeshed/blob/cc674b5dcef0c14612e79be255d0b2a8b0e11f81/stubs/beautifulsoup4/bs4/__init__.pyi#L19
@sobolevn sobolevn added bug mypy got something wrong topic-stubtest labels Apr 9, 2023
@jorenham
Copy link
Contributor

For NumPy, this results in many duplicate allowlist entries. Many functions like floor_divide are duplicated 8 times, leading to a bloated allowlist: https://github.com/numpy/numtype/blob/4e161170a694b7802c448a0dd5c959c7b0a80790/.mypyignore-todo
It's also pretty annoying that a single error leads to 40+ lines of error output (--concise helps, but is often too concise).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-stubtest
Projects
None yet
Development

No branches or pull requests

2 participants