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

Tests: Add test case for settings import cycle #2098

Merged
merged 2 commits into from
May 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/typecheck/conf/test_settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- case: test_setting_circular_import
main: |
from myapp import lib
custom_settings: |
from myapp.lib import function_returning_int

IMMEDIATE_VALUE = 123
CIRCULAR_WITHOUT_HINT = function_returning_int()
CIRCULAR_WITH_HINT: int = function_returning_int()
files:
- path: myapp/__init__.py
- path: myapp/lib.py
content: |
from django.conf import settings

def test() -> None:
reveal_type(settings.IMMEDIATE_VALUE) # N: Revealed type is "builtins.int"
reveal_type(settings.CIRCULAR_WITHOUT_HINT) # E: Import cycle from Django settings module prevents type inference for 'CIRCULAR_WITHOUT_HINT' [misc] # N: Revealed type is "Any"
reveal_type(settings.CIRCULAR_WITH_HINT) # N: Revealed type is "builtins.int"

def function_returning_int() -> int:
return 42
Loading