Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django fkey detection #596

Merged
merged 4 commits into from
Feb 5, 2025
Merged

Django fkey detection #596

merged 4 commits into from
Feb 5, 2025

Conversation

emdoyle
Copy link
Member

@emdoyle emdoyle commented Feb 4, 2025

This PR plugs into the 'processing' stage of the tach check pipeline.

In addition to extracting imports from the AST, this PR introduces a specialized visitor which finds ForeignKey calls, and extracts the to field when it is a string literal. This is useful because it may avoid a direct import, but still create a cross-module dependency.

To support this, there is also an AST visitor which runs once up-front to extract the INSTALLED_APPS from the configured Django settings module. This allows us to resolve the string literals used in ForeignKey, which are typically of the form <app_label>.<model>.

@emdoyle emdoyle force-pushed the django-fkey-detection branch from 1c49011 to cbb32e3 Compare February 5, 2025 21:39
@emdoyle emdoyle changed the base branch from generalize-processors to generalize-imports February 5, 2025 21:39
Base automatically changed from generalize-imports to main February 5, 2025 22:18
@emdoyle emdoyle force-pushed the django-fkey-detection branch from 57f8105 to d240fa0 Compare February 5, 2025 22:19
@emdoyle emdoyle merged commit 6ea439f into main Feb 5, 2025
7 of 11 checks passed
@emdoyle emdoyle deleted the django-fkey-detection branch February 5, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant