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

Add strict_settings option, allow runtime fallbacks for custom settings #1557

Merged
merged 15 commits into from
Jun 24, 2023

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jun 20, 2023

This PR adds a new setting to our plugin called strict_settings.
When set to True (the default), it raises for any statically unknown setting value.

But, when set to False, it checks for the runtime setting value and if it is present, it returns Any in all cases.

This will change will make it possible to use django-stubs with django-split-settings (which I maintain and use for all my projects) and similar tools like django-configurations.

After #1163 it was very hard to use settings in dynamic workflows.

Closes #1410
Closes #1276
Closes #417

@sobolevn sobolevn requested review from intgr and adamchainz June 20, 2023 12:55
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
tests/typecheck/test_settings.yml Show resolved Hide resolved
```ini
[mypy.plugins.django-stubs]
strict_settings = false
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Although there are just 2 settings for now, I would prefer it if all django-stubs settings were documented in one place. Maybe add another README section for settings and then link to it from here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we can do this later. Good idea 👍

mypy_django_plugin/config.py Show resolved Hide resolved
@intgr
Copy link
Collaborator

intgr commented Jun 21, 2023

When I try to run this in one of my projects, I get the following error. Haven't investigated at all.

mypy 1.4.0 (compiled: yes)
Traceback (most recent call last):
  File ".../bin/mypy", line 8, in <module>
Error constructing plugin instance of NewSemanalDRFPlugin

    sys.exit(console_entry())
             ^^^^^^^^^^^^^^^
  File ".../lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
  File "mypy/main.py", line 95, in main
  ...
  File "mypy/build.py", line 484, in load_plugins_from_config
  File ".../lib/python3.11/site-packages/mypy_drf_plugin/main.py", line 26, in __init__
    self.django_context = DjangoContext(django_settings_module)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.11/site-packages/mypy_django_plugin/django/context.py", line 85, in __init__
    apps, settings = initialize_django(self.plugin_config.django_settings_module)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'django_settings_module'

@intgr
Copy link
Collaborator

intgr commented Jun 21, 2023

Looks like some interaction between djangorestframework-stubs and django-stubs.

@sobolevn
Copy link
Member Author

sobolevn commented Jun 21, 2023

Oh, good catch! I've change the signature of DjangoContext, so we would need to change it here as well: https://github.com/typeddjango/djangorestframework-stubs/blob/8709db5d2af980919a46072725ab54ca637a8703/mypy_drf_plugin/main.py#L25-L26

I've opened typeddjango/djangorestframework-stubs#432

@UnknownPlatypus
Copy link
Contributor

If I understand well, this makes it possible to use django-stubs along django-configuration or django-split-settings but the types inferred will be Any right ?

To have more accurate typing, one should make his own plugin ?

@sobolevn
Copy link
Member Author

If I understand well, this makes it possible to use django-stubs along django-configuration or django-split-settings but the types inferred will be Any right ?

Yes!

To have more accurate typing, one should make his own plugin ?

I can work on this later on, I need a way to infer mypy types from runtime types. I have a prototype that does just this. But, I need to polish it for a bit more.

@sobolevn sobolevn requested a review from intgr June 23, 2023 03:48
@sobolevn
Copy link
Member Author

I want to merge this today, so I can work on #1568

@intgr any other comments? :)

@sobolevn sobolevn merged commit 3caea3f into master Jun 24, 2023
@sobolevn sobolevn deleted the issue-1410 branch June 24, 2023 20:07
Copy link
Collaborator

@intgr intgr left a comment

Choose a reason for hiding this comment

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

Sorry, I was away for a few days. But looks good to me now.

@sobolevn
Copy link
Member Author

sobolevn commented Jun 26, 2023

No worries, happy to see that you like my fix :)

descope bot referenced this pull request in descope/django-descope Jul 18, 2023
This PR contains the following updates:

| Package | Type | Update | Change | Pending |
|---|---|---|---|---|
| [django-stubs](https://github.com/typeddjango/django-stubs)
([changelog](https://github.com/typeddjango/django-stubs/releases)) |
dev | patch | `4.2.1` -> `4.2.2` | `4.2.3` |

---

### Release Notes

<details>
<summary>typeddjango/django-stubs (django-stubs)</summary>

###
[`v4.2.2`](https://github.com/typeddjango/django-stubs/releases/tag/4.2.2)

[Compare
Source](https://github.com/typeddjango/django-stubs/compare/4.2.1...4.2.2)

#### Headline changes

-   **mypy 1.4:** Recommended mypy version updated to 1.4.x
- Support for `django-split-settings`, `django-configurations` and other
Django settings addons with `strict_settings = false` option, [see
README for
details](https://github.com/typeddjango/django-stubs#how-to-use-a-custom-library-to-handle-django-settings)
- We have now adopted [mypy's
stubtest](https://mypy.readthedocs.io/en/stable/stubtest.html) to
automatically find discrepancies between Django and django-stubs.

If you want to contribute to django-stubs but are not sure where to
start, have a look at [stubtest's TODO
list](https://github.com/typeddjango/django-stubs/blob/master/scripts/stubtest/allowlist_todo.txt)
file, which lists the many issues discovered by stubtest.

##### Django 4.2 changes

- Applied Django 4.2 deprecations by
[@&#8203;Alexerson](https://github.com/Alexerson) in
[https://github.com/typeddjango/django-stubs/pull/1523](https://github.com/typeddjango/django-stubs/pull/1523)
- Updated global settings and `AppConfig` class to match Django 4.2 by
[@&#8203;Alexerson](https://github.com/Alexerson) in
[https://github.com/typeddjango/django-stubs/pull/1524](https://github.com/typeddjango/django-stubs/pull/1524)
- Added types for new 'system checks' in Django 4.2 by
[@&#8203;Alexerson](https://github.com/Alexerson) in
[https://github.com/typeddjango/django-stubs/pull/1526](https://github.com/typeddjango/django-stubs/pull/1526)
- Added `ManifestStaticFilesStorage` new parameters by
[@&#8203;Alexerson](https://github.com/Alexerson) in
[https://github.com/typeddjango/django-stubs/pull/1528](https://github.com/typeddjango/django-stubs/pull/1528)
- Added new methods to `Sitemap` class by
[@&#8203;Alexerson](https://github.com/Alexerson) in
[https://github.com/typeddjango/django-stubs/pull/1527](https://github.com/typeddjango/django-stubs/pull/1527)
- Added new `headers=` parameter to `(Async)RequestFactory` and
`(Async)Client` classes by
[@&#8203;Alexerson](https://github.com/Alexerson) in
[https://github.com/typeddjango/django-stubs/pull/1529](https://github.com/typeddjango/django-stubs/pull/1529)
- Additional fixes by [@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1537](https://github.com/typeddjango/django-stubs/pull/1537)
- GDAL-related GeoDjango updates in Django 4.2 by
[@&#8203;Alexerson](https://github.com/Alexerson) in
[https://github.com/typeddjango/django-stubs/pull/1525](https://github.com/typeddjango/django-stubs/pull/1525)
- Added ORM `^` and `~` operator support, JSON lookup classes, Postgres
lookup classes, `ModelForm` changes, `json_script` template filter
parameters by [@&#8203;Alexerson](https://github.com/Alexerson) in
[https://github.com/typeddjango/django-stubs/pull/1536](https://github.com/typeddjango/django-stubs/pull/1536)
- Added and updated `db.backends` `DatabaseIntrospection` and
`DatabaseOperations` classes by
[@&#8203;GabDug](https://github.com/GabDug) in
[https://github.com/typeddjango/django-stubs/pull/1571](https://github.com/typeddjango/django-stubs/pull/1571)

##### Stubs additions

- Added `QuerySet._result_cache` attribute and `_fetch_all()` method by
[@&#8203;adamchainz](https://github.com/adamchainz) in
[https://github.com/typeddjango/django-stubs/pull/1505](https://github.com/typeddjango/django-stubs/pull/1505)
- Added `ModelAdmin.search_help_text` attribute by
[@&#8203;adamchainz](https://github.com/adamchainz) in
[https://github.com/typeddjango/django-stubs/pull/1546](https://github.com/typeddjango/django-stubs/pull/1546)
- Added email console handler `EmailBackend.write_message()` method by
[@&#8203;adamchainz](https://github.com/adamchainz) in
[https://github.com/typeddjango/django-stubs/pull/1547](https://github.com/typeddjango/django-stubs/pull/1547)
- Added `ModelAdmin.get_formset_kwargs()` method by
[@&#8203;adamchainz](https://github.com/adamchainz) in
[https://github.com/typeddjango/django-stubs/pull/1545](https://github.com/typeddjango/django-stubs/pull/1545)
- Added `Signal._live_receivers()` method by
[@&#8203;adamchainz](https://github.com/adamchainz) in
[https://github.com/typeddjango/django-stubs/pull/1551](https://github.com/typeddjango/django-stubs/pull/1551)
- Added `SQLCompiler._order_by_pairs()` method by
[@&#8203;adamchainz](https://github.com/adamchainz) in
[https://github.com/typeddjango/django-stubs/pull/1586](https://github.com/typeddjango/django-stubs/pull/1586)
- Added `memcache_key_warnings()` function by
[@&#8203;rvanlaar](https://github.com/rvanlaar) in
[https://github.com/typeddjango/django-stubs/pull/1562](https://github.com/typeddjango/django-stubs/pull/1562)

##### Stubs fixes

- Fixed `create_model_instance` incorrect data argument type by
[@&#8203;namper](https://github.com/namper) in
[https://github.com/typeddjango/django-stubs/pull/1521](https://github.com/typeddjango/django-stubs/pull/1521)
- Marked `RequestSite.{save,delete}` methods as `NoReturn` since they
always raise by [@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1530](https://github.com/typeddjango/django-stubs/pull/1530)
- Updated `SafeExceptionReporterFilter` attributes and removed obsolete
`CLEANSED_SUBSTITUTE` by
[@&#8203;mthuurne](https://github.com/mthuurne) in
[https://github.com/typeddjango/django-stubs/pull/1540](https://github.com/typeddjango/django-stubs/pull/1540)
- Changed `AppConfig.default_auto_field` to attribute instead of method
by [@&#8203;mthuurne](https://github.com/mthuurne) in
[https://github.com/typeddjango/django-stubs/pull/1541](https://github.com/typeddjango/django-stubs/pull/1541)
- Fixed `default_error_messages` attribute type of base `Field` and
`GenericIPAddressField` classes by
[@&#8203;asottile](https://github.com/asottile) in
[https://github.com/typeddjango/django-stubs/pull/1538](https://github.com/typeddjango/django-stubs/pull/1538)
- Improved spatialite `DatabaseWrapper` attributes by
[@&#8203;filbasi](https://github.com/filbasi) in
[https://github.com/typeddjango/django-stubs/pull/1544](https://github.com/typeddjango/django-stubs/pull/1544)
- Improved types for Signal `dispatch.dispatcher` by
[@&#8203;GabDug](https://github.com/GabDug) in
[https://github.com/typeddjango/django-stubs/pull/1567](https://github.com/typeddjango/django-stubs/pull/1567)
- Accept `str` field names for `Window.order_by()`, allow `None` for
`asc/desc` arguments by [@&#8203;GabDug](https://github.com/GabDug) in
[https://github.com/typeddjango/django-stubs/pull/1574](https://github.com/typeddjango/django-stubs/pull/1574)
- Updated many `django.utils.*` types from stubtest by
[@&#8203;GabDug](https://github.com/GabDug) in
[https://github.com/typeddjango/django-stubs/pull/1575](https://github.com/typeddjango/django-stubs/pull/1575)
- Updated many `db.migrations.operations` types from stubtest by
[@&#8203;GabDug](https://github.com/GabDug) in
[https://github.com/typeddjango/django-stubs/pull/1583](https://github.com/typeddjango/django-stubs/pull/1583)
- Added `StepValueValidator`, fixed argument for
`SRIDCacheEntry`/`EmailValidator`, improved `urls.resolvers` types by
[@&#8203;GabDug](https://github.com/GabDug) in
[https://github.com/typeddjango/django-stubs/pull/1589](https://github.com/typeddjango/django-stubs/pull/1589)

##### Plugin changes

- Fixed `ForeignKey` queryset filters on un-swapped models by
[@&#8203;UnknownPlatypus](https://github.com/UnknownPlatypus) in
[https://github.com/typeddjango/django-stubs/pull/1495](https://github.com/typeddjango/django-stubs/pull/1495)
- Add `strict_settings` option, allow runtime fallbacks for custom
settings by [@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1557](https://github.com/typeddjango/django-stubs/pull/1557)
- Add "Settings" section to README by
[@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1581](https://github.com/typeddjango/django-stubs/pull/1581)
- Automatically reset mypy cache when plugin settings change by
[@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1578](https://github.com/typeddjango/django-stubs/pull/1578)
- Fixed unhandled exception `KeyError: 'model_bases'` and related errors
by [@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1563](https://github.com/typeddjango/django-stubs/pull/1563)

##### django-stubs-ext

- Added `TypedDatabaseRouter` as database router base class by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1522](https://github.com/typeddjango/django-stubs/pull/1522)

##### CI/testing

- CI: Replace isort with Ruff import sorting by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1507](https://github.com/typeddjango/django-stubs/pull/1507)
- CI: Auto-remove unused imports using Ruff by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1508](https://github.com/typeddjango/django-stubs/pull/1508)
- CI: Enable Ruff pyupgrade fixes by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1509](https://github.com/typeddjango/django-stubs/pull/1509)
- CI: Run django-stubs-ext tests in full build matrix by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1552](https://github.com/typeddjango/django-stubs/pull/1552)
- Remove typecheck test and clean things up by
[@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1556](https://github.com/typeddjango/django-stubs/pull/1556)
- Add stubtest with lots of errors (currently) by
[@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1560](https://github.com/typeddjango/django-stubs/pull/1560)
- Removed extra `--generate-allowlist` by
[@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1576](https://github.com/typeddjango/django-stubs/pull/1576)

##### Housekeeping

- Removed unsupported Django versions from package classifiers by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1553](https://github.com/typeddjango/django-stubs/pull/1553)
- Removed try-except around import of `ArrayField` by
[@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1558](https://github.com/typeddjango/django-stubs/pull/1558)
- Reverted: Fix crash when psycopg2 is not installed by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1565](https://github.com/typeddjango/django-stubs/pull/1565)
- Removed usage of `mypy_extensions` by
[@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1566](https://github.com/typeddjango/django-stubs/pull/1566)
- Upgrade to Mypy 1.4.0 by
[@&#8203;christianbundy](https://github.com/christianbundy) in
[https://github.com/typeddjango/django-stubs/pull/1572](https://github.com/typeddjango/django-stubs/pull/1572)
- Chore: set Black Python target to 3.8+ explicitely by
[@&#8203;GabDug](https://github.com/GabDug) in
[https://github.com/typeddjango/django-stubs/pull/1573](https://github.com/typeddjango/django-stubs/pull/1573)
- Update `flake8` plugins by
[@&#8203;sobolevn](https://github.com/sobolevn) in
[https://github.com/typeddjango/django-stubs/pull/1579](https://github.com/typeddjango/django-stubs/pull/1579)
- CI: Run tests and pre-commit using newest Python version by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1582](https://github.com/typeddjango/django-stubs/pull/1582)
- Removed duplicate "import all" test file by
[@&#8203;adamchainz](https://github.com/adamchainz) in
[https://github.com/typeddjango/django-stubs/pull/1587](https://github.com/typeddjango/django-stubs/pull/1587)
- Update compatible-mypy to 1.4.x by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1588](https://github.com/typeddjango/django-stubs/pull/1588)
- Version 4.2.2 release (django-stubs, django-stubs-ext) by
[@&#8203;intgr](https://github.com/intgr) in
[https://github.com/typeddjango/django-stubs/pull/1590](https://github.com/typeddjango/django-stubs/pull/1590)

#### New Contributors

- [@&#8203;namper](https://github.com/namper) made their first
contribution in
[https://github.com/typeddjango/django-stubs/pull/1521](https://github.com/typeddjango/django-stubs/pull/1521)
- [@&#8203;filbasi](https://github.com/filbasi) made their first
contribution in
[https://github.com/typeddjango/django-stubs/pull/1544](https://github.com/typeddjango/django-stubs/pull/1544)
- [@&#8203;GabDug](https://github.com/GabDug) made their first
contribution in
[https://github.com/typeddjango/django-stubs/pull/1567](https://github.com/typeddjango/django-stubs/pull/1567)
- [@&#8203;rvanlaar](https://github.com/rvanlaar) made their first
contribution in
[https://github.com/typeddjango/django-stubs/pull/1562](https://github.com/typeddjango/django-stubs/pull/1562)

**Full Changelog**:
typeddjango/django-stubs@4.2.1...4.2.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xLjExIiwidXBkYXRlZEluVmVyIjoiMzYuMS4xMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: descope[bot] <descope[bot]@users.noreply.github.com>
@kaldown
Copy link

kaldown commented Sep 13, 2023

This do not work with django-configurations.

[tool.mypy]
mypy_path = "./src"
plugins = ["mypy_django_plugin.main"]

[tool.django-stubs]
django_settings_module = "myproj.settings"
strict_settings = false

returns an Error:

Error constructing plugin instance of NewSemanalDjangoPlugin
...
raise ImproperlyConfigured(install_failure)
django.core.exceptions.ImproperlyConfigured: django-configurations settings importer wasn't correctly installed. Please use one of the starter functions to install it as mentioned in the docs: https://django-configurations.readthedocs.io/

Whilst commenting usage of django-stubs in [tool.mypy] directive of pyproject.toml leading to expected issue of mypy not being able to catch django types from models.py (for example).

As I see this PR #180 is still open.
Would it be better to remove django-configurations entry from README.md since it could cause confusion?

@intgr
Copy link
Collaborator

intgr commented Sep 13, 2023

@kaldown Please open a separate issue about this.

@kaldown
Copy link

kaldown commented Sep 13, 2023

@intgr thank you, for the fast reply. Do you think it's better to open another one in addition to #180?

@intgr
Copy link
Collaborator

intgr commented Sep 13, 2023

Yes.

@kaldown
Copy link

kaldown commented Sep 13, 2023

Done: #1709

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants