Skip to content

fix(hook-decorator): upgrade django-lifecycle and remove type: ignore[misc] comments#7890

Open
afsuyadi wants to merge 2 commits into
Flagsmith:mainfrom
afsuyadi:fix/mypy-type-error
Open

fix(hook-decorator): upgrade django-lifecycle and remove type: ignore[misc] comments#7890
afsuyadi wants to merge 2 commits into
Flagsmith:mainfrom
afsuyadi:fix/mypy-type-error

Conversation

@afsuyadi

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • [✔] I have read the Contributing Guide.
  • [ ] I have added information to docs/ if required so people know about the feature.
  • [✔] I have filled in the "Changes" section below.
  • [✔] I have filled in the "How did you test this code" section below.

Changes

Contributes to #5240

  1. Upgraded django-lifecycle from 1.2.4 to 1.2.5 in pyproject.toml (both the version constraint and the pinned dev dependency)
  2. Removed 24 # type: ignore[misc] comments from @hook-decorated methods across 10 files

How did you test this code?

  1. Run make typecheck; pass with no [misc] errors
  2. Ran make test locally for those 10 files; 2041 tests passed, 0 failures.

Cli:
DJANGO_SETTINGS_MODULE=app.settings.test ./flagsmith/api/.venv/bin/pytest tests/unit/audit/ tests/unit/environments/ tests/unit/features/ tests/unit/projects/ tests/unit/users/ tests/unit/integrations/

Screenshot from 2026-06-26 19-36-24

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

@afsuyadi is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@afsuyadi afsuyadi requested a review from a team as a code owner June 26, 2026 12:51
@afsuyadi afsuyadi requested review from emyller and removed request for a team June 26, 2026 12:51
@github-actions github-actions Bot added the api Issue related to the REST API label Jun 26, 2026
@emyller

emyller commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Hi @afsuyadi thanks for this contribution! I've unblocked uv lock (7ee256e) to solve this error, but we've now uncovered a few typing errors. 😬

How do you think we should proceed?

@afsuyadi afsuyadi force-pushed the fix/mypy-type-error branch from 7ee256e to 9a1f573 Compare July 2, 2026 01:48
@afsuyadi afsuyadi force-pushed the fix/mypy-type-error branch from 9a1f573 to bf2ae79 Compare July 3, 2026 01:11
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request bumps the pinned django-lifecycle dependency version from 1.2.4 to 1.2.5 in api/pyproject.toml, and removes now-unneeded # type: ignore[misc] comments from @hook(...) decorators across numerous Django model files (audit, environments, experimentation, features, feature external resources, release pipelines, workflows, github integrations, projects, and users). One hook call's keyword-argument formatting was also reformatted. No runtime logic or public API signatures were changed.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Changes

Cohort / File(s) Change Summary
Dependency bump api/pyproject.toml Bumped django-lifecycle version constraint and uv override from 1.2.4 to 1.2.5
Hook decorator cleanup api/audit/models.py, api/environments/models.py, api/experimentation/models.py, api/features/feature_external_resources/models.py, api/features/models.py, api/features/release_pipelines/core/models.py, api/features/workflows/core/models.py, api/integrations/github/models.py, api/projects/models.py, api/users/models.py Removed obsolete # type: ignore[misc] comments from @hook(...) decorators; minor kwargs formatting change in one Celery task call

Sequence Diagram(s)

Not applicable — this change consists solely of comment removals and a dependency version bump with no observable behavioural or flow changes.

Related issues: None referenced in the provided changes.

Related PRs: None referenced in the provided changes.

Suggested labels: dependencies, chore, type-check

Suggested reviewers: None specifically indicated by the diff content.

Poem:
A rabbit hopped through model files bright,
Snipping stale ignores left and right,
No logic bent, no tests to fright,
Just tidier hooks and a version's slight height,
django-lifecycle now shines 1.2.5 tonight. 🐇


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9a90c458-5cd3-4344-a6ab-fce04c9e3b68

📥 Commits

Reviewing files that changed from the base of the PR and between e77c851 and bf2ae79.

📒 Files selected for processing (11)
  • api/audit/models.py
  • api/environments/models.py
  • api/experimentation/models.py
  • api/features/feature_external_resources/models.py
  • api/features/models.py
  • api/features/release_pipelines/core/models.py
  • api/features/workflows/core/models.py
  • api/integrations/github/models.py
  • api/projects/models.py
  • api/pyproject.toml
  • api/users/models.py

Comment thread api/pyproject.toml
@afsuyadi

afsuyadi commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi @afsuyadi thanks for this contribution! I've unblocked uv lock (7ee256e) to solve this error, but we've now uncovered a few typing errors. 😬

How do you think we should proceed?

I think the errors are caused by upgrading django-lifecycle, and it adds type stubs.

By observing the logs, it seems there are two categories of error: [unused-ignore] and [no-untyped-call].

  • [unused-ignore] is probably caused by # type: ignore comments across the codebase that are no longer needed after the upgrade. The fix for this error would be removing the stale # type: ignore comments from all affected files.
  • [no-untyped-call] is happening because there are untyped functions from django-lifecycle itself. The fix for this error would be adding # type: ignore[no-untyped-call] with a reason on each affected line,
    CMIIW.

However, I am unsure of whether to fix all of them in this PR or split this out.

Should I fix all of these in this PR, or open a separate PR dedicated to the typing fixes? @emyller

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

Labels

api Issue related to the REST API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants