Skip to content

Incomplete types for now(tz=...) methods #607

Open

Description

@mfulgo
  • I am on the latest Pendulum version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • OS version and name: n/a

  • Pendulum version: 2.1.2

Issue

The functions pendulum.now and DateTime.now are currently typed with

Optional[Union[str, _Timezone]]

However, the underlying _safe_timezone function also accepts int and float. (Though, it's type doesn't declare int, only float, that should be okay because of mypy's duck typing...)

I'm pretty sure Line 201 should be changed to

def now(tz: Optional[Union[str, float, Timezone]] = None) -> DateTime:

and Line 118 should be changed to

    def now(cls, tz: Optional[Union[str, float, Timezone]] = None) -> "DateTime":

These also may need to include _datetime.tzinfo, but I wasn't sure about the indirect import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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