Commit Graph

28 Commits

Author SHA1 Message Date
Maxim Kurnikov
29ac1c3017 Split AddManagers for model in separate stages to process IncompleteDefnException properly (#171) 2019-09-18 02:20:20 +03:00
Maxim Kurnikov
23ad65033b add custom Field processing for mixins used in the Model subclasses (#167) 2019-09-18 01:40:41 +03:00
Maxim Kurnikov
2b53fa5a1a Fix typecheck tests ci (#165)
* remove mention of mypy newsemanal to prepare for 0.730

* make typecheck_tests CI really work

* fix lints

* fix intentional error

* merge stderr in stdout to preserve order

Co-authored-by: Daniel Hahler <github@thequod.de>
2019-09-16 14:35:13 +03:00
Maxim Kurnikov
e95b40ef52 stability fixes 2019-08-24 17:04:50 +03:00
Maxim Kurnikov
4c21855641 fix mypy errors 2019-07-25 18:52:51 +03:00
Maxim Kurnikov
4dfa363521 lint fixes 2019-07-24 13:38:50 +03:00
Maxim Kurnikov
2c001fd8a7 cleanups 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
d7d379e1cd create dummy classes for custom_manager_of_model usecase 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
248504c25a various fixes 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
fee4aad3d0 fix OneToOneField without related_name 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
fc9843bea6 add support for _meta.get_field() typechecking 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
5bb1bc250d add get_next_by_FOO, get_previous_by_FOO for date,datetime fields 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
1721c997be add support for get_FIELD_display for choices fields 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
07a9bcd4cb remove dataclasses dependency 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
b81fbdeaa9 remove -semanal suffix 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
dc6101b569 remove old semanal plugin data 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
b11a9a85f9 new semanal wip 1 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
9c5a6be9a7 split helpers into smaller files 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
5dd6eccdb5 make ignore_missing_model_attributes behaviour optional (#66)
make "ignore_missing_model_attributes" behaviour opt-in
2019-04-12 17:22:18 +03:00
Maxim Kurnikov
aeb435c8b3 Disable monkeypatches, add dependencies via new hook (#60)
* code cleanups, disable monkeypatches, move to add_additional_deps

* disable incremental mode for tests

* add pip-wheel-metadata

* move some code from get_base_hook to get_attribute_hook to reduce dependencies

* simplify values/values_list tests and code

* disable cache for some tests failing with incremental mode

* enable incremental mode for tests typechecking

* pin mypy version

* fix tests

* lint

* fix internal crashes
2019-04-12 14:54:00 +03:00
Seth Yastrov
71fb0432f3 52/model subtypes dont typecheck (#55)
* Fix problem where Model instancess are not considered subtypes of each other due to fallback_to_any = True. Fixes #52.

- Added a stub for __getstate__ to Model.
- Added a stub for clean() to Model.
- Correct arg type for sort_dependencies so they are covariant (Iterable rather than List).

Test ignores:
- Added some test ignores in cases where a model inherits from 2 different base models.
- Added some test ignores for cases that MyPy flags as errors due to variable redefinitions or imports that are incompatible types.

* Address review comment.
2019-03-28 23:13:02 +03:00
Seth Yastrov
5b455b729a Specific return types for values and values list (#53)
* Instead of using Literal types, overload QuerySet.values_list in the plugin. Fixes #43.

- 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.

* Determine better row types for values_list/values based on fields specified.

- In the case of values_list, we use a Row type with either a single primitive, Tuple, or NamedTuple.
- In the case of values, we use a TypedDict.
- In both cases, Any is used as a fallback for individual fields if those fields cannot be resolved.

A couple other fixes I made along the way:
- Don't create reverse relation for ForeignKeys with related_name='+'
- Don't skip creating other related managers in AddRelatedManagers if a dynamic value is encountered
  for related_name parameter, or if the type cannot be determined.

* Fix for TypedDict so that they are considered anonymous.

* Clean up some comments.

* Implement making TypedDict anonymous in a way that doesn't crash sometimes.

* Fix flake8 errors.

* Remove even uglier hack about making TypedDict anonymous.

* Address review comments. Write a few better comments inside tests.

* Fix crash when running with mypyc ("interpreted classes cannot inherit from compiled") due to the way I extended TypedDictType.

- Implemented the hack in another way that works on mypyc.
- Added a couple extra tests of accessing 'id' / 'pk' via values_list.

* Fix flake8 errors.

* Support annotation expressions (use type Any) for TypedDicts row types returned by values_list.

- Bonus points: handle values_list gracefully (use type Any) where Tuples are returned
  where some of the fields arguments are not string literals.
2019-03-25 12:53:09 +03:00
Maxim Kurnikov
18c908bf98 set plugin_generated on new symbol nodes 2019-03-05 20:15:46 +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
14ea848dd7 add nested Meta inheritance support for forms 2019-02-20 21:52:28 +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
e9f9202ed1 preliminary support for strict_optional 2019-02-17 18:07:53 +03:00