Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@chalmerlowe
Copy link
Collaborator

Replaced calls to deprecated datetime.datetime.utcnow() with datetime.datetime.now(datetime.UTC) in tests/unit/job/test_base.py.

Replaced calls to deprecated datetime.datetime.utcfromtimestamp() with datetime.datetime.fromtimestamp(timestamp, datetime.UTC) in tests/unit/job/helpers.py.

These changes address the specific warnings identified in the issue for these two files.

Example 1: utcnow():

/tmpfs/src/github/python-bigquery/tests/unit/job/test_base.py:334: DeprecationWarning:
datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use
timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    now = datetime.datetime.utcnow().replace(

Example 2: utcfromtimestamp():

/tmpfs/src/github/python-bigquery/tests/unit/job/helpers.py:109: DeprecationWarning:
datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future
version. Use timezone-aware objects to represent datetimes in UTC:
datetime.datetime.fromtimestamp(timestamp, datetime.UTC).

Replaced calls to deprecated `datetime.datetime.utcnow()` with
`datetime.datetime.now(datetime.UTC)` in `tests/unit/job/test_base.py`.

Replaced calls to deprecated `datetime.datetime.utcfromtimestamp()` with
`datetime.datetime.fromtimestamp(timestamp, datetime.UTC)` in
`tests/unit/job/helpers.py`.

These changes address the specific warnings identified in the issue
for these two files.
@chalmerlowe chalmerlowe requested review from a team as code owners May 14, 2025 18:48
@chalmerlowe chalmerlowe requested a review from Linchin May 14, 2025 18:48
@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: bigquery Issues related to the googleapis/python-bigquery API. labels May 14, 2025
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: xs Pull request size is extra small. labels May 14, 2025
@chalmerlowe chalmerlowe merged commit 5805066 into main May 15, 2025
18 checks passed
@chalmerlowe chalmerlowe deleted the fix-datetime-warnings branch May 15, 2025 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants