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

[MNT]: Where to use_api.check_in_list #24828

Open
@oscargus

Description

@oscargus

Summary

There's been some discussion how the "best" way to write if-clauses depending on a text parameter in combination with_api.check_in_list, e.g.#24486 (comment)

Proposed fix

There are three primary ways in the code base:

  1. Explicit checking all arguments twice
_api.check_in_list(["foo","bar"],param=param)ifparam=="foo":     ...elifparam=="bar":    ...
  1. Skip explicit checking of the last argument
_api.check_in_list(["foo","bar"],param=param)ifparam=="foo":     ...else:# "bar"    ...
  1. Use_api.check_in_list for generating an error message once we know that no option is matching.
ifparam=="foo":     ...elifparam=="bar":    ...else:_api.check_in_list(["foo","bar"],param=param)

Personally, I'm in favor of 2. Primarily as it skips a redundant check and that it is not possible to get 100% coverage in case 1. Also, it is often the case that the_api.check_in_list is done in another place in the code (like in the constructor), so option 3 may lead to a delayed error.

I know that@timhoffm prefers 1 as that is more likely to lead to errors if a case is missed in the if-part.

(In addition, this should really be called_api.check_in_tuple and tuples being used as this will have some performance benefits when it comes to compiled code. Parts of the code use tuples already though...)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp