Skip to content

fix(time): replace datetime.utcnow() with timezone-aware now(UTC) + asyncio test config#17

Open
RTHYMS wants to merge 1 commit into
kcolbchain:mainfrom
RTHYMS:contrib/asyncio-deps-and-deprecation
Open

fix(time): replace datetime.utcnow() with timezone-aware now(UTC) + asyncio test config#17
RTHYMS wants to merge 1 commit into
kcolbchain:mainfrom
RTHYMS:contrib/asyncio-deps-and-deprecation

Conversation

@RTHYMS

@RTHYMS RTHYMS commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Two issues surfaced by running `pytest` on Python 3.14:

1. async tests in `tests/test_basescan.py` were silently failing

4 `@pytest.mark.asyncio` tests had no pytest-asyncio plugin in dev deps and no `asyncio_mode` set, so pytest treated the coroutines as bare functions and failed them with:

```
Failed: async def functions are not natively supported.
You need to install a suitable plugin for your async framework.
```

Fix: add `pytest-asyncio` to `[project.optional-dependencies].dev` + `asyncio_mode = "auto"` under `[tool.pytest.ini_options]`.

2. `datetime.utcnow()` deprecation

`scout/registry.py` and the test_scoring `FakeActivity` factory used `datetime.utcnow()` (2 sites in production code, 1 in tests). Python 3.12 emits `DeprecationWarning` and 3.14 may remove it.

Replace with `datetime.now(timezone.utc)` — timezone-aware, identical instant.

Result

```
29 passed in 0.17s
```

(was 25 passed, 4 failed, 11 warnings)

Drive-by

CI workflow + badge.

…syncio test config

Two issues found by running pytest on Python 3.14:

1. async tests in tests/test_basescan.py were silently failing because
   pytest-asyncio wasn't in dev deps and no asyncio_mode was set. Add
   pytest-asyncio + asyncio_mode = "auto" so async tests actually run.

2. registry.py and the test_scoring FakeActivity factory both used
   datetime.utcnow(), which emits DeprecationWarning on 3.12+ and will
   be removed in a future Python. Switch to datetime.now(timezone.utc).

Also: wire CI workflow + badge.
@abhicris

Copy link
Copy Markdown
Contributor

Welcome to kcolbchain, @RTHYMS — glad you're here. 🌱

Here's what happens from this PR:

  1. Our automated review looks for obvious issues (tests, secrets, size) within a couple of hours.
  2. If it's clean and CI passes, we merge without back-and-forth.
  3. If we need changes, we'll leave a specific comment — not a generic nit. Push another commit and we re-review.

While you wait:

  • Run the repo's tests locally (see the repo README.md).
  • Keep the PR scoped to one concern — bigger PRs land slower.
  • Don't commit tokens or .env contents.

What happens after your first merge

Thanks for writing the code. We're building this to last.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants