Skip to content

Commit

Permalink
Update type stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke committed Sep 4, 2024
1 parent 3a866f6 commit c2f71d1
Showing 1 changed file with 50 additions and 13 deletions.
63 changes: 50 additions & 13 deletions faker/proxy.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -959,21 +959,23 @@ class Faker:
:param pattern: Format of the date (year-month-day by default)
:example: '2008-11-27'
:return: Date
:return: string
"""
...

def date_between(
self,
start_date: Union[datetime.date, datetime.datetime, datetime.timedelta, str, int] = ...,
end_date: Union[datetime.date, datetime.datetime, datetime.timedelta, str, int] = ...,
) -> datetime.date:
pattern: Optional[str] = ...,
) -> Union[datetime.date, str]:
"""
Get a Date object based on a random date between two given dates.
Accepts date strings that can be recognized by strtotime().
:param start_date: Defaults to 30 years ago
:param end_date: Defaults to "today"
:param pattern: optional pattern to format the date as string
:example: Date('1999-02-02')
:return: Date
"""
Expand All @@ -982,14 +984,16 @@ class Faker:
def date_between_dates(
self,
date_start: Union[datetime.date, datetime.datetime, datetime.timedelta, str, int, None] = ...,
date_end: Union[datetime.date, datetime.datetime, datetime.timedelta, str, int, None] = ...,
) -> datetime.date:
date_end: Union[datetime.date, datetime.datetime, datetime.timedelta, str, int, None] = ...,,
pattern: Optional[str] = ...,
) -> Union[datetime.date, str]:
"""
Takes two Date objects and returns a random date between the two given dates.
Accepts Date or datetime objects
:param date_start: Date
:param date_end: Date
:param pattern: optional pattern to format the date as string
:return: Date
"""
...
Expand All @@ -1003,8 +1007,12 @@ class Faker:
...

def date_of_birth(
self, tzinfo: Optional[datetime.tzinfo] = ..., minimum_age: int = ..., maximum_age: int = ...
) -> datetime.date:
self,
tzinfo: Optional[datetime.tzinfo] = ...,
minimum_age: int = ...,
maximum_age: int = ...,
pattern: Optional[str] = ...,
) -> Union[datetime.date, str]:
"""
Generate a random date of birth represented as a Date object,
constrained by optional miminimum_age and maximum_age
Expand All @@ -1013,51 +1021,76 @@ class Faker:
:param tzinfo: Defaults to None.
:param minimum_age: Defaults to 0.
:param maximum_age: Defaults to 115.
:param pattern: optional pattern to format the date as string
:example: Date('1979-02-02')
:return: Date
"""
...

def date_this_century(self, before_today: bool = ..., after_today: bool = ...) -> datetime.date:
def date_this_century(
self,
before_today: bool = ...,
after_today: bool = ...,
pattern: Optional[str] = ...,
) -> Union[datetime.date, str]:
"""
Gets a Date object for the current century.
:param before_today: include days in current century before today
:param after_today: include days in current century after today
:param pattern: optional pattern to format the date as string
:example: Date('2012-04-04')
:return: Date
"""
...

def date_this_decade(self, before_today: bool = ..., after_today: bool = ...) -> datetime.date:
def date_this_decade(
self,
before_today: bool = ...,
after_today: bool = ...,
pattern: Optional[str] = ...,
) -> Union[datetime.date, str]:
"""
Gets a Date object for the decade year.
:param before_today: include days in current decade before today
:param after_today: include days in current decade after today
:param pattern: optional pattern to format the date as string
:example: Date('2012-04-04')
:return: Date
"""
...

def date_this_month(self, before_today: bool = ..., after_today: bool = ...) -> datetime.date:
def date_this_month(
self,
before_today: bool = ...,
after_today: bool = ...,
pattern: Optional[str] = ...,
) -> Union[datetime.date, str]:
"""
Gets a Date object for the current month.
:param before_today: include days in current month before today
:param after_today: include days in current month after today
:param pattern: optional pattern to format the date as string
:example: dtdate('2012-04-04')
:return: dtdate
"""
...

def date_this_year(self, before_today: bool = ..., after_today: bool = ...) -> datetime.date:
def date_this_year(
self,
before_today: bool = ...,
after_today: bool = ...,
pattern: Optional[str] = ...,
) -> Union[datetime.date, str]:
"""
Gets a Date object for the current year.
:param before_today: include days in current year before today
:param after_today: include days in current year after today
:param pattern: optional pattern to format the date as string
:example: Date('2012-04-04')
:return: Date
"""
Expand Down Expand Up @@ -1190,15 +1223,17 @@ class Faker:
def future_date(
self,
end_date: Union[datetime.date, datetime.datetime, datetime.timedelta, str, int] = ...,
tzinfo: Optional[datetime.tzinfo] = ...,
) -> datetime.date:
tzinfo: Optional[datetime.tzinfo] = ...,,
pattern: Optional[str] = ...,
) -> Union[datetime.date, str]:
"""
Get a Date object based on a random date between 1 day from now and a
given date.
Accepts date strings that can be recognized by strtotime().
:param end_date: Defaults to "+30d"
:param tzinfo: timezone, instance of datetime.tzinfo subclass
:param pattern: optional pattern to format the date as string
:example: dtdate('2030-01-01')
:return: dtdate
"""
Expand Down Expand Up @@ -1244,14 +1279,16 @@ class Faker:
self,
start_date: Union[datetime.date, datetime.datetime, datetime.timedelta, str, int] = ...,
tzinfo: Optional[datetime.tzinfo] = ...,
) -> datetime.date:
pattern: Optional[str] = ...,
) -> Union[datetime.date, str]:
"""
Get a Date object based on a random date between a given date and 1 day
ago.
Accepts date strings that can be recognized by strtotime().
:param start_date: Defaults to "-30d"
:param tzinfo: timezone, instance of datetime.tzinfo subclass
:param pattern: optional pattern to format the date as string
:example: dtdate('1999-02-02')
:return: dtdate
"""
Expand Down

0 comments on commit c2f71d1

Please sign in to comment.