Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

question to the signature of list.index #134025

Closed as not planned
Closed as not planned
Labels
docsDocumentation in the Doc dir
@weipeng1999

Description

@weipeng1999

Recently I switch to use pyright as my lsp server. This server is very strict at type annotation, and I found some errors as following.

  error: Type "list[int]" is not assignable to declared type "SequenceNotStr[int]"    "list[int]" is incompatible with protocol "SequenceNotStr[int]"      "index" is an incompatible type        Type "(value: int, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int" is not assignable to type "(value: Any, /, start: int = 0, stop: int = ...) -> int"          Missing keyword parameter "start"          Missing keyword parameter "stop"            Position-only parameter mismatch; parameter "start" is not position-only            Position-only parameter mismatch; parameter "stop" is not position-only (reportAssignmentType)1 error, 0 warnings, 0 informations

so I check the "index" signature of list.index and SequenceNotStr.index, found that:

>>>inspect.signature(list.index)<Signature (self,value,start=0,stop=9223372036854775807,/)>>>>inspect.signature(pd_typing.SequenceNotStr.index)<Signature (self,value:'Any',/,start:'int'=0,stop:'int'=Ellipsis)->'int'>

The signature of list.index make me surprised. Why we set start and stop as the position-only argument to the list.index? I think defined them as position-and-keyword argument is a better idea, so that we can using keyword to set them. Meanwhile i think give default value to position-only argument is a little strange

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp