Skip to content

Prefer using literal types over enums #576

@vdusek

Description

@vdusek
  • We should prefer typing.Literal types over enum.Enum.

Motivation

  • Better developer experience - Literals can be passed directly as values, without requiring additional imports.
  • Type safety is preserved - When used with a type checker, Literal types provide the same level of safety as enums.
  • Fewer footguns - The usage of enums can easily lead to bugs like this one: fix: Fix force permissions serialization for Actor calls #575.
  • Consistency across our tooling - We already prefer literals in Crawlee and the SDK.

Scope

Compatibility

  • This is a breaking change, so it should be tracked and implemented as part of apify-python-client v3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    debtCode quality improvement or decrease of technical debt.t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions