Commit Graph

67 Commits

Author SHA1 Message Date
Seth Yastrov
b1a04d2f7d Instead of using Literal types, overload QuerySet.values_list in the plugin. Fixes #43. (#44)
- Add a couple of extra type checks that Django makes:
  1) 'flat' and 'named' can't be used together.
  2) 'flat' is not valid when values_list is called with more than one field.
2019-03-13 22:10:37 +03:00
Seth Yastrov
324b961d74 Support returning the correct values for the different QuerySet methods when using .values() and .values_list(). (#33)
* Support returning the correct values for the different QuerySet methods when using .values() and .values_list().

* Fix slicing on QuerySet. Fix django queries test, and remove some ignored errors that are no longer needed.

* Remove accidental change in RawQuerySet.

* Readded some still-necessary ignores to aggregation django test.

* Add more tests of first/last/earliest/last/__getitem__, per mkurnikov's comments.

- Fix .iterator()

* Re-add Iterator as base-class of QuerySet.

* Make QuerySet a Collection.

* - Fix return type for QuerySet.select_for_update().
- Use correct return type for QuerySet.dates() / QuerySet.datetimes().
- Use correct type params in return type for QuerySet.__and__ / QuerySet.__or__
- Re-add Sized as base class for QuerySet.
- Add test of .all() for all _Row types.
- Add test of .get() for all _Row types.
- Remove some redundant QuerySet method tests.

* Automatically fill in second type parameter for QuerySet.

... if second parameter is omitted.
2019-03-10 12:13:50 +03:00
Seth Yastrov
86c63d790b Fix type errors on other models' managers when using objects = models.Manager() in Model. (#34)
* Fix bug where models with a class variable using a manager defined would interfere with other managers.

- Fill in the type argument for that particular instance of the manager, rather than modifying the bases of the Manager type.
- Instantiate a new Instance from determine_proper_manager_type so The code doesn't crash under mypy-mypyc.

* Use helpers.reparametrize_instance per review comment.

* Updated ignored errors in Django test for get_objects_or_404.

- For some reason, `Manager[nothing]` is now removed from expected types.
  However, I think this makes sense anyway, as Manager is a subclass of QuerySet.
2019-03-08 12:30:38 +03:00
Richard Eames
f7dfbefbd6 Make CharField(blank=True) not be considered nullable (#39)
* Make CharField(blank=True) not be considered nullable

The documentation on [blank](https://docs.djangoproject.com/en/2.1/ref/models/fields/#blank) says that it "will allow the entry of an empty value", which for a string is just a 0-length string. This patch allows `CharField(blank=True,...)` to no longer be considered `Optional`.

closes #38

* fixed tests for `CharField(blank=True)`

* allow blank CharField to be nullable in the constructor, but the underlying type
is str (unless `null=True`)
2019-03-06 01:37:44 +03:00
Maxim Kurnikov
18c908bf98 set plugin_generated on new symbol nodes 2019-03-05 20:15:46 +03:00
Maxim Kurnikov
e0e8814804 Revert "dont convert to optional, if anytype"
This reverts commit 53f5d2214b.
2019-03-05 19:11:02 +03:00
Maxim Kurnikov
53f5d2214b dont convert to optional, if anytype 2019-03-05 18:43:10 +03:00
Maxim Kurnikov
18445f686f set fallback= for ini parser 2019-03-01 02:25:15 +03:00
Maxim Kurnikov
c962b8ac68 attempt to add flake8 and isort 2019-03-01 02:07:53 +03:00
Maxim Kurnikov
df5c70c703 fixes for FormMixin's get_form/get_form_class 2019-02-25 04:01:36 +03:00
Maxim Kurnikov
dacf88c692 optimize hooks a bit 2019-02-22 00:12:23 +03:00
Maxim Kurnikov
14ea848dd7 add nested Meta inheritance support for forms 2019-02-20 21:52:28 +03:00
Maxim Kurnikov
5d8cdbcf29 fix integer set type 2019-02-20 02:38:45 +03:00
Maxim Kurnikov
ab73d53ae5 add support for models defined in the same module be specified as name of class in related fields 2019-02-19 00:43:27 +03:00
Maxim Kurnikov
f980311be0 finish strict_optional support, enable it for typechecking of django tests 2019-02-18 00:52:56 +03:00
Maxim Kurnikov
e9f9202ed1 preliminary support for strict_optional 2019-02-17 18:07:53 +03:00
Maxim Kurnikov
c382d6aa2f fix redefining field with name id with different than int type 2019-02-15 21:54:40 +03:00
Maxim Kurnikov
c1640b619f fix stale import 2019-02-14 03:21:11 +03:00
Maxim Kurnikov
a08ad80a0d fix star import parsing for settings 2019-02-14 03:16:07 +03:00
Maxim Kurnikov
f30cd092f1 add default for MYPY_DJANGO_CONFIG 2019-02-13 23:02:49 +03:00
Maxim Kurnikov
26a80a8279 add properly typed FOREIGN_KEY_FIELD_NAME_id fields to models 2019-02-13 21:05:02 +03:00
Maxim Kurnikov
79ebe20f2e add more test folders 2019-02-13 19:44:25 +03:00
Maxim Kurnikov
4a22da29cb add support for default related managers, fixes #18 2019-02-13 17:11:22 +03:00
Maxim Kurnikov
70378b8f40 preserve fallback to Any for unrecognized field types for init/create 2019-02-13 17:00:35 +03:00
Maxim Kurnikov
b7f7713c5a add support for get_user_model(), fixes #16 2019-02-13 15:56:21 +03:00
Maxim Kurnikov
9eb95fbab3 add BaseManager.create() typechecking 2019-02-12 03:54:48 +03:00
Maxim Kurnikov
6b7507206a fix couple edge cases with __init__ 2019-02-10 04:32:27 +03:00
Maxim Kurnikov
5f6f597266 add config file support 2019-02-09 03:21:49 +03:00
Maxim Kurnikov
916df1efb6 add Model.__init__ typechecking 2019-02-08 17:16:03 +03:00
Maxim Kurnikov
dead370244 fix ci 2019-02-07 20:58:12 +03:00
Maxim Kurnikov
d4cb729c93 rework settings, add loading of the django.conf.global_settings, cleanups 2019-02-07 19:13:39 +03:00
Maxim Kurnikov
191496ed72 enable some test folders, bunch of fixes 2019-02-07 00:08:05 +03:00
Maxim Kurnikov
d43cb1fcd7 fixes 2019-02-06 22:20:12 +03:00
Maxim Kurnikov
69d4ccaf54 fixes, add some testing folders 2019-02-04 19:31:37 +03:00
Maxim Kurnikov
19e9cd7ffc fix failing plugin tests 2019-01-31 18:33:19 +03:00
Maxim Kurnikov
628c1224d6 enable test typechecking for a bunch of django test suite folders 2019-01-30 15:56:59 +03:00
Maxim Kurnikov
38e841c4c7 look for models.Model in full mro for to= parameter 2019-01-25 17:23:34 +03:00
Maxim Kurnikov
5a0f00dde1 fix problem with TypeVar bound to Model passed as a parameter 2019-01-24 18:59:41 +03:00
Maxim Kurnikov
cff5ab463c fix tests 2019-01-22 20:13:31 +03:00
Maxim Kurnikov
77aba97bdc remove legacy monkeypatch 2019-01-22 20:12:36 +03:00
Maxim Kurnikov
4f33f28ba2 fix tests 2019-01-22 19:30:09 +03:00
Maxim Kurnikov
87877774cd fix problems with 0.660 2019-01-20 18:57:26 +03:00
Maxim Kurnikov
f070098ce5 self reference support for foreignkeys 2018-12-21 23:46:10 +03:00
Maxim Kurnikov
2f58cdae88 RefExpr in determining model fullname not supported 2018-12-21 01:49:10 +03:00
Maxim Kurnikov
3c3e9305f4 add support for Apps.get_model for migrations 2018-12-21 01:17:47 +03:00
Maxim Kurnikov
094b8421ab move to plugin common api, move to new functioncontext api 2018-12-19 02:41:28 +03:00
Maxim Kurnikov
c9ad40d7e3 add support for managers as generics 2018-12-07 22:11:22 +03:00
Maxim Kurnikov
94ddb8c864 remove 'need type annotation for setting' error message 2018-12-06 19:38:27 +03:00
Maxim Kurnikov
447651c770 do not emit error, if attribute does not exist 2018-12-06 17:45:27 +03:00
Maxim Kurnikov
3676cb3ac0 solve more use cases for related managers and settings 2018-12-03 01:57:46 +03:00