question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugin calls `ready` of all installed apps

See original GitHub issue

Bug report

What’s wrong

django-stubs calls apps.populate(settings.INSTALLED_APPS) which in turn calls ready on all apps. And that requires all imports to be present and even can execute SQL queries.

  File "/usr/local/lib/python3.8/site-packages/mypy_django_plugin/main.py", line 71, in __init__
    self.django_context = DjangoContext(self.plugin_config.django_settings_module)
  File "/usr/local/lib/python3.8/site-packages/mypy_django_plugin/django/context.py", line 97, in __init__
    apps, settings = initialize_django(self.django_settings_module)
  File "/usr/local/lib/python3.8/site-packages/mypy_django_plugin/django/context.py", line 81, in initialize_django
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
...
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "..." does not exist

How is that should be

What’s the purpose of calling apps.populate? would it be possible to avoid calling ready on apps and still do what django-stubs needs to do? If I understand correctly, you need only imports to be executed, right? If it sounds interesting I could look into mocking app_config.ready() calls.

Related: #1060

System information

  • OS: Linux Mint
  • python version: 3.8.13
  • django version: 3.2.15
  • mypy version: 0.971
  • django-stubs version: 1.12.0
  • django-stubs-ext version: 0.5.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
flaeppecommented, Sep 2, 2022

Haha, yes, you’re right. It’s me being confused, mixing up what’s runtime and not

0reactions
orsiniumcommented, Sep 2, 2022

And that’s the big difference between mypy and django-stubs. The latter actually executes the code, and so potentially suffers from all possible slow-downs, loops, and side-effects. And the issue is about finding a way to avoid it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing your installed apps
Managing app location and order · On the My apps page, click the Reorder apps button on the top right. The Reorder apps...
Read more >
Viewing installed apps | Atlassian Support
To view the list of apps in your cloud product: From the top navigation bar in your product, select Settings ( ). Select...
Read more >
Native: tried calling plugins, but the plugin is not installed. · ...
My app is not working right on android 4.4 because plugins don't install. Do you have any idea ? package.json: "dependencies": { "@angular/ ......
Read more >
windows - List all installed software on PC
Fire up your console and type: wmic product get name,version. It takes a while, but you'll get the full list of installed programs....
Read more >
Build a calling app
A calling app allows users to receive or place audio or video calls on their device. Calling apps use their own user interface...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found