Commit Graph

524 Commits

Author SHA1 Message Date
Ville Skyttä
dd5b98faf0 django.contrib.messages.api: use HttpRequest instead of WSGIRequest (#73)
Its error messages explicitly note that an HttpRequest is required.
https://docs.djangoproject.com/en/2.1/_modules/django/contrib/messages/api/#add_message
2019-05-21 17:23:19 +03:00
Ethan Smith
e634a5d460 Re-export names from django.core.cache.backend.base (#71) 2019-05-19 19:59:14 +03:00
aszlig
d7d7e6c66e Fix type of prefix arg in staticfiles_urlpatterns (#74)
Using a *type* of None for the prefix keyword argument is not going to
typecheck very well, so it might be a typo here because the default
value (rather than the type) is None.

Signed-off-by: aszlig <aszlig@nix.build>
2019-05-19 19:59:00 +03:00
Anthony Ricaud
b66727657d Type non-parametrised views.decorators.http (#80)
Fixes `error: Untyped decorator makes function "view" untyped`
2019-05-17 20:40:40 +03:00
Maxim Kurnikov
86642e3ddd bump version v0.12.1 2019-04-15 14:50:43 +03:00
Maciej Gol
952e1c3ee9 Preserve callable type in view decorators (#67) 2019-04-13 22:31:49 +03:00
Maxim Kurnikov
5dd6eccdb5 make ignore_missing_model_attributes behaviour optional (#66)
make "ignore_missing_model_attributes" behaviour opt-in
v0.12.0
2019-04-12 17:22:18 +03:00
Maxim Kurnikov
fd06816cbb Work around "no settings module" crash (#65)
Workaround "no settings module" crash
2019-04-12 17:14:23 +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
Maxim Kurnikov
13d19017b7 bump version v0.11.1 2019-04-01 19:40:13 +03:00
Maxim Kurnikov
28a3f126ee make mypy.checker import locally to prevent import cycles 2019-04-01 19:39:50 +03:00
Maxim Kurnikov
304cb19de6 really drop universal v0.11.0 2019-04-01 01:43:14 +03:00
Maxim Kurnikov
c57f4f7152 only python3.6+ are supported 2019-04-01 01:08:46 +03:00
Maxim Kurnikov
8a826fee1e bump version 2019-04-01 00:54:36 +03:00
Maxim Kurnikov
37d85c2ca6 pin mypy version, django-stubs not yet supports mypyc 2019-04-01 00:54:15 +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
Maxim Kurnikov
9288c34648 fix @classproperty return type (#58) 2019-03-27 23:13:10 +03:00
Maxim Kurnikov
70050f28b9 drop --universal 2019-03-26 03:23:25 +03:00
Maxim Kurnikov
4338c17970 bump version 2019-03-25 14:22:17 +03:00
Maxim Kurnikov
91f789c38c fix SessionBase.exists() return type (#57) 2019-03-25 14:21:12 +03:00
Maxim Kurnikov
0f5b45fba1 bump version v0.10.0 2019-03-25 13:31:41 +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
5c6be7ad12 Add test to import all modules to check validity of stubs (#56)
* add import_all.test builder

* fix errors

* fix typechecking errors

* fix migrations typechecking
2019-03-25 01:57:34 +03:00
Maxim Kurnikov
5d0ee40ada Fix errors in db.models.expressions and db.models.functions.* (#54)
* fix errors at db.models.expressions and db.models.functions.*

* catch KeyError if QuerySet has not been loaded
2019-03-24 02:54:10 +03:00
Konstantin Alekseev
77f15d7478 Configure black using pyproject.toml (#50) 2019-03-18 16:53:12 +03:00
Konstantin Alekseev
4f83d8d1bb Use less specific types in validators args (#49) 2019-03-18 13:31:35 +03:00
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
Maxim Kurnikov
7c57143310 forms/__init__ reimports 2019-03-10 21:14:15 +03:00
Maxim Kurnikov
c3d76f9a1e bump version v0.9.0 2019-03-10 20:03:00 +03:00
Maxim Kurnikov
fde071b883 fix classonlymethod, replace with six from typeshed 2019-03-10 19:56:54 +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
Matt Basta
050c1b8887 Add gzip_page decorator (#41)
* Add gzip_page decorator

* Update to preserve Callable
2019-03-06 21:16:24 +03:00
Maxim Kurnikov
8978ad471f bump version v0.8.2 2019-03-06 12:05:24 +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
627daa55f5 fix extension of django.views __init__ file 2019-03-06 01:28:42 +03:00
Maxim Kurnikov
194489ee8d bump version v0.8.1 2019-03-05 20:21:43 +03:00
Maxim Kurnikov
1d2c7fb805 Remove _Val alias for MultiValueDict so that generic evaluate (#36)
* remove _Val alias for MultiValueDict so that generic evaluate

* fix multivaluedict init argument
2019-03-05 20:16:24 +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
9e4ed70fc5 Disable note: messages (#35)
* add global note: ignore
2019-03-01 05:15:05 +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
70c3126348 add plugin testing for python3.6 2019-02-27 18:12:29 +03:00
Maxim Kurnikov
af8ecc5520 remove django from dependencies, it's not required for static analysis 2019-02-27 18:11:54 +03:00
Maxim Kurnikov
64f8870d0b bump version v0.8.0 2019-02-27 17:59:04 +03:00
Maxim Kurnikov
df5c70c703 fixes for FormMixin's get_form/get_form_class 2019-02-25 04:01:36 +03:00
Maxim Kurnikov
c09a97e005 Merge pull request #29 from syastrov/queryset_in_bulk
QuerySet.in_bulk returns Dict with values of correct model type.
2019-02-22 23:23:36 +03:00
Seth Yastrov
0e30821ad3 Add possibility to pass list of test names as command-line arguments to typecheck_tests.py script. 2019-02-22 20:03:30 +01:00