Skip to content

[stubtest] Improve checking of positional-only parameters in dunder methods #19593

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brianschubert
Copy link
Member

@brianschubert brianschubert commented Aug 4, 2025

Currently, mypy treats all special methods as being implicitly positional-only. This creates a blind spot for stubtest, since it means that stubtest isn't sensitive to whether special method in stub files are typed as being positional-only or not.

This PR adds an internal option to disable the positional-only-special-method heuristic when running stubtest. This way, stubtest can see the actual stub signatures as written in the stub files, making it possible to meaningfully compare them against the runtime signatures.

Now, stubtest will warn about dunder methods that are positional-only at runtime but keyword-or-positional in the stubs. Note that it still doesn't warn about the reverse (keyword-or-positional at runtime but positional-only in the stubs). The latter might be worth revisiting as well, but the typeshed hits are less obvious and there are a number of cases where this is done deliberately that would need allowlist entries.

@brianschubert
Copy link
Member Author

brianschubert commented Aug 4, 2025

New typeshed stdlib hits1 (CI run):

$ cat *stubtest\ stdlib*.txt | tr -d '\r' | sed -e 's/\x1b[^m]*m//g' | cut -d' ' -f2- | grep '^error' | LC_ALL=C sort | uniq 
error: _collections_abc.dict_items.__and__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__contains__ is inconsistent, stub argument "item" should be positional-only (add "/", e.g. "key, /")
error: _collections_abc.dict_items.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__or__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__rand__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__ror__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__rsub__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__rxor__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__sub__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_items.__xor__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__and__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__contains__ is inconsistent, stub argument "key" should be positional-only (add "/", e.g. "key, /")
error: _collections_abc.dict_keys.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__or__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__rand__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__ror__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__rsub__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__rxor__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__sub__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _collections_abc.dict_keys.__xor__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _contextvars.Token.__exit__ is inconsistent, stub argument "exc_type" should be positional-only (add "/", e.g. "type, /")
error: _contextvars.Token.__exit__ is inconsistent, stub argument "exc_value" should be positional-only (add "/", e.g. "val, /")
error: _contextvars.Token.__exit__ is inconsistent, stub argument "traceback" should be positional-only (add "/", e.g. "tb, /")
error: _interpchannels.ChannelID.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _interpchannels.ChannelID.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _interpchannels.ChannelID.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _interpchannels.ChannelID.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _interpchannels.ChannelID.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _interpchannels.ChannelID.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: array.array.__contains__ is inconsistent, stub argument "value" should be positional-only (add "/", e.g. "key, /")
error: contextvars.Token.__exit__ is inconsistent, stub argument "exc_type" should be positional-only (add "/", e.g. "type, /")
error: contextvars.Token.__exit__ is inconsistent, stub argument "exc_value" should be positional-only (add "/", e.g. "val, /")
error: contextvars.Token.__exit__ is inconsistent, stub argument "traceback" should be positional-only (add "/", e.g. "tb, /")
error: importlib.metadata.EntryPoint.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: typing.ParamSpec.__or__ is inconsistent, stub argument "right" should be positional-only (add "/", e.g. "value, /")
error: typing.ParamSpec.__ror__ is inconsistent, stub argument "left" should be positional-only (add "/", e.g. "value, /")
error: typing.ParamSpec.__typing_prepare_subst__ is inconsistent, stub argument "alias" should be positional-only (add "/", e.g. "alias, /")
error: typing.ParamSpec.__typing_prepare_subst__ is inconsistent, stub argument "args" should be positional-only (add "/", e.g. "args, /")
error: typing.ParamSpec.__typing_subst__ is inconsistent, stub argument "arg" should be positional-only (add "/", e.g. "arg, /")
error: typing.ParamSpecArgs.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: typing.ParamSpecKwargs.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: typing.TypeAliasType.__getitem__ is inconsistent, stub argument "parameters" should be positional-only (add "/", e.g. "key, /")
error: typing.TypeAliasType.__or__ is inconsistent, stub argument "right" should be positional-only (add "/", e.g. "value, /")
error: typing.TypeAliasType.__ror__ is inconsistent, stub argument "left" should be positional-only (add "/", e.g. "value, /")
error: typing.TypeVar.__or__ is inconsistent, stub argument "right" should be positional-only (add "/", e.g. "value, /")
error: typing.TypeVar.__ror__ is inconsistent, stub argument "left" should be positional-only (add "/", e.g. "value, /")
error: typing.TypeVar.__typing_prepare_subst__ is inconsistent, stub argument "alias" should be positional-only (add "/", e.g. "alias, /")
error: typing.TypeVar.__typing_prepare_subst__ is inconsistent, stub argument "args" should be positional-only (add "/", e.g. "args, /")
error: typing.TypeVar.__typing_subst__ is inconsistent, stub argument "arg" should be positional-only (add "/", e.g. "arg, /")
error: typing.TypeVarTuple.__typing_prepare_subst__ is inconsistent, stub argument "alias" should be positional-only (add "/", e.g. "alias, /")
error: typing.TypeVarTuple.__typing_prepare_subst__ is inconsistent, stub argument "args" should be positional-only (add "/", e.g. "args, /")
error: typing.TypeVarTuple.__typing_subst__ is inconsistent, stub argument "arg" should be positional-only (add "/", e.g. "arg, /")
error: typing_extensions.TypeAliasType.__getitem__ is inconsistent, stub argument "parameters" should be positional-only (add "/", e.g. "key, /")
error: typing_extensions.TypeAliasType.__or__ is inconsistent, stub argument "right" should be positional-only (add "/", e.g. "value, /")
error: typing_extensions.TypeAliasType.__ror__ is inconsistent, stub argument "left" should be positional-only (add "/", e.g. "value, /")
error: winreg.HKEYType.__exit__ is inconsistent, stub argument "exc_type" should be positional-only (add "/", e.g. "exc_type, /")
error: winreg.HKEYType.__exit__ is inconsistent, stub argument "exc_value" should be positional-only (add "/", e.g. "exc_value, /")
error: winreg.HKEYType.__exit__ is inconsistent, stub argument "traceback" should be positional-only (add "/", e.g. "traceback, /")

New typeshed third-party stub hits1 (CI run):

$ cat *stubtest\ third*.txt | tr -d '\r' | sed -e 's/\x1b[^m]*m//g' | cut -d' ' -f2- | grep '^error' | LC_ALL=C sort | uniq 
error: _cffi_backend._CDataBase.__add__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__delitem__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "key, /")
error: _cffi_backend._CDataBase.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: _cffi_backend._CDataBase.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__radd__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__rsub__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__setitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: _cffi_backend._CDataBase.__setitem__ is inconsistent, stub argument "object" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend._CDataBase.__sub__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend.buffer.__delitem__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "key, /")
error: _cffi_backend.buffer.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend.buffer.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend.buffer.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: _cffi_backend.buffer.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend.buffer.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend.buffer.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend.buffer.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: _cffi_backend.buffer.__setitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: _cffi_backend.buffer.__setitem__ is inconsistent, stub argument "object" should be positional-only (add "/", e.g. "value, /")
error: braintree.attribute_getter.AttributeGetter.__getattribute__ is inconsistent, stub argument "name" should be positional-only (add "/", e.g. "name, /")
error: gdb.Type.__getitem__ is inconsistent, stub argument "key" should be positional-only (add "/", e.g. "key, /")
error: gdb.Value.__add__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__and__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__getitem__ is inconsistent, stub argument "key" should be positional-only (add "/", e.g. "key, /")
error: gdb.Value.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__lshift__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__mod__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__mul__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__or__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__pow__ is inconsistent, stub argument "mod" should be positional-only (add "/", e.g. "mod, /")
error: gdb.Value.__pow__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__radd__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__rmod__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__rmul__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__rshift__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__rsub__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__rtruediv__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__sub__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__truediv__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gdb.Value.__xor__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: gevent.local.local.__delattr__ is inconsistent, stub argument "name" should be positional-only (add "/", e.g. "name, /")
error: gevent.local.local.__getattribute__ is inconsistent, stub argument "name" should be positional-only (add "/", e.g. "name, /")
error: gevent.local.local.__setattr__ is inconsistent, stub argument "name" should be positional-only (add "/", e.g. "name, /")
error: gevent.local.local.__setattr__ is inconsistent, stub argument "value" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.ExtensionDict.__contains__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.ExtensionDict.__delitem__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.ExtensionDict.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.ExtensionDict.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.ExtensionDict.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.ExtensionDict.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.ExtensionDict.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.ExtensionDict.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.ExtensionDict.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.ExtensionDict.__setitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.ExtensionDict.__setitem__ is inconsistent, stub argument "object" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.Message.__contains__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "object, /")
error: google._upb._message.Message.__delattr__ is inconsistent, stub argument "name" should be positional-only (add "/", e.g. "name, /")
error: google._upb._message.Message.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.Message.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.Message.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.Message.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.Message.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.Message.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.Message.__setattr__ is inconsistent, stub argument "name" should be positional-only (add "/", e.g. "name, /")
error: google._upb._message.Message.__setattr__ is inconsistent, stub argument "value" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedCompositeContainer.__delitem__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.RepeatedCompositeContainer.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedCompositeContainer.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedCompositeContainer.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.RepeatedCompositeContainer.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedCompositeContainer.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedCompositeContainer.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedCompositeContainer.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedCompositeContainer.__setitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.RepeatedCompositeContainer.__setitem__ is inconsistent, stub argument "object" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedScalarContainer.__delitem__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.RepeatedScalarContainer.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedScalarContainer.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedScalarContainer.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.RepeatedScalarContainer.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedScalarContainer.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedScalarContainer.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedScalarContainer.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.RepeatedScalarContainer.__setitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: google._upb._message.RepeatedScalarContainer.__setitem__ is inconsistent, stub argument "object" should be positional-only (add "/", e.g. "value, /")
error: google._upb._message.UnknownFieldSet.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: hdbcli.dbapi.ResultRow.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: hdbcli.resultrow.ResultRow.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: pika.exchange_type.ExchangeType.__format__ is inconsistent, stub argument "format_spec" should be positional-only (add "/", e.g. "format_spec, /")
error: psycopg2.Error.__setstate__ is inconsistent, stub argument "state" should be positional-only (add "/", e.g. "object, /")
error: psycopg2._psycopg.Column.__setstate__ is inconsistent, stub argument "state" should be positional-only (add "/", e.g. "object, /")
error: psycopg2._psycopg.Error.__setstate__ is inconsistent, stub argument "state" should be positional-only (add "/", e.g. "object, /")
error: psycopg2.errors.Error.__setstate__ is inconsistent, stub argument "state" should be positional-only (add "/", e.g. "object, /")
error: psycopg2.extensions.Column.__setstate__ is inconsistent, stub argument "state" should be positional-only (add "/", e.g. "object, /")
error: shapely.Geometry.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.Geometry.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.Geometry.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.Geometry.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.Geometry.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.Geometry.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.geometry.base.BaseGeometry.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.geometry.base.BaseGeometry.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.lib.Geometry.__eq__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.lib.Geometry.__ge__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.lib.Geometry.__gt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.lib.Geometry.__le__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.lib.Geometry.__lt__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: shapely.lib.Geometry.__ne__ is inconsistent, stub argument "other" should be positional-only (add "/", e.g. "value, /")
error: win32.win32security.PySecBufferDescType.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: win32.win32security.SecBufferDescType.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: win32security.PySecBufferDescType.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")
error: win32security.SecBufferDescType.__getitem__ is inconsistent, stub argument "index" should be positional-only (add "/", e.g. "key, /")

Footnotes

  1. excluding those resolved by python/typeshed#14523 2

Copy link
Contributor

github-actions bot commented Aug 4, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@brianschubert
Copy link
Member Author

brianschubert commented Aug 6, 2025

I think this is ready for review. At this point I've gone through all of the new typeshed hits: all were true positives, and most have been corrected in typeshed.

The only remaining errors are in _collections_abc, and are related to the fact that some collections.abc dunder methods are typed as accepting keyword-arguments but have concrete implementations that are positional-only at runtime. Based on the discussion in python/cpython#135312, it seems that there's a consensus that these dunder methods should eventually be re-typed as positional-only, which would make the new stubtest hits go away. That may or may not happen before an updated version of stubtest reaches typeshed. If it doesn't, the new errors could be silenced with a small number of allowlist entries.

@brianschubert brianschubert marked this pull request as ready for review August 6, 2025 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant