Skip to content

Add types-str2bool #12259

@ZivRonen

Description

@ZivRonen

str2bool is a small library that was updated twice 7 years and was not touched ever since, so I don't believe it will be updated in the future.

A quick search indicate that there isn't a good replacement. The answers in https://stackoverflow.com/questions/715417/converting-from-a-string-to-boolean-in-python show some promises:

  • Using distutils.util.strtobool, but it will be deprecated in Python 3.12. It also return weird int value, not bool.
  • pydantic.parse_obj_as(bool, value), or the newer: pydantic.TypeAdapter(bool).validate_python(value). pydantic is an overkill if you only want it for this, and it is not equivalent as it support on, off (for instance).
  • yaml.parse - but it will allow values like "2"

And, regardless of whether it should still be used, it is used and should have types support.

I will make a small pull request to check it in the near future, but I create an issue as requested in CONTRIBUTING.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: requestOUTDATED! Request to add stubs for a new package to typeshed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions