Peter Law
2d11e02fdb
Remove redundant invalid documentation line
...
This is now replaced by the type signature.
2021-07-24 17:12:34 +01:00
Peter Law
392dcdf015
Fix potential bug passing exception to function excepting str
...
Found while adding type annotations.
2021-07-24 17:12:34 +01:00
Peter Law
b9fd84e11c
Add sanity-check exception
...
Found by mypy while adding types.
2021-07-24 17:12:34 +01:00
Peter Law
75624f0e3c
Convert more things to Python 3 idioms
2021-07-24 17:12:34 +01:00
Peter Law
6ad62e18d2
deque is in collections, not queue
...
Though it seems that the queue module does use it internally, which
is why this was working.
2021-07-24 17:12:34 +01:00
Peter Law
cce3ecb1e4
Use the default handling of optionals
...
This is strict handling, but allows implicit declarations.
2020-08-04 21:49:42 +01:00
Peter Law
6364dd1511
Add explicit Optional annotation
...
This isn't a mypy issue -- there's no way it could otherwise know
that this `None` value is in fact an optional callable.
2020-07-26 14:43:41 +01:00
Peter Law
19b8eaea59
Link mypy issue
2020-07-26 13:26:14 +01:00
Peter Law
b892c07841
Merge branch 'master' into mypy
2020-07-26 12:25:19 +01:00
Peter Law
cefc363f64
Configure mypy and flake8 for our re-export files
...
This removes the need to use __all__ in these files, while also
allowing us to have strictness elsewhere in the codebase.
2020-07-26 12:20:08 +01:00
Peter Law
45c90efb5c
Remove a couple of unused imports
2020-07-26 12:17:54 +01:00
Peter Law
0571e12617
These attributes aren't optional
...
They just don't yet have a value.
2020-07-26 12:11:34 +01:00
Peter Law
86e0e16625
Drop redundant rtype comment
...
This is better expressed as an annotation.
2020-07-26 12:10:59 +01:00
Peter Law
b3edda30c4
Explain why we 'type: ignore' these properties
2020-07-26 12:09:04 +01:00
Peter Law
a9cb9fbb1f
Give a bit more detail here
2020-07-24 21:06:30 +01:00
Peter Law
3f74981d5e
Also typecheck sith
2020-07-24 21:06:30 +01:00
Peter Law
38f853cf86
Add ignores for stdlib imports only recently added
2020-07-24 21:06:30 +01:00
Peter Law
4b7e837f0f
Configure the package root as implicit exports
2020-07-24 20:25:55 +01:00
Peter Law
a2d9fbcd42
Ignore this runtime-only import
...
I've queried this in https://github.com/python/typeshed/issues/4360 ,
though I suspect the answer is going to be to have an ignore comment
like this.
2020-07-24 20:25:55 +01:00
Peter Law
6315709fea
Inherit from base class to placate mypy
2020-07-24 20:25:55 +01:00
Peter Law
48e5aa777b
Annotate potentially missing import
2020-07-24 20:25:55 +01:00
Peter Law
69be26b16e
Change subclass to function wrapper
...
This avoids mypy complaining that we need to provide a generic
argument to Popen, which we cannot acctually do as the implementation
of Popen does not inherit from typing.Generic.
2020-07-24 20:25:55 +01:00
Peter Law
5e509814f7
Ignore mypy not coping with decorated properties
2020-07-24 20:25:55 +01:00
Peter Law
07fbcd2262
Make this explicitly expect a Path
2020-07-24 20:25:55 +01:00
Peter Law
1c87ae378d
This is a Path now
2020-07-24 20:25:55 +01:00
Peter Law
b1f95b4bf9
Annotate these attributes
2020-07-24 16:10:34 +01:00
Peter Law
7d9205d4ae
This is actually optional
2020-07-24 16:10:34 +01:00
Peter Law
9b3cd15c5f
Fix type clash
2020-07-24 16:10:34 +01:00
Peter Law
1418aada91
Annotate top level items mypy needs annotating
2020-07-24 16:10:34 +01:00
Peter Law
f98a9f7999
Annotate the completions cache
2020-07-24 16:10:34 +01:00
Peter Law
35c2d660cb
Fix most import related mypy errors
2020-07-24 16:10:34 +01:00
Peter Law
c09e21ae4b
Configure mypy
...
No fixes yet, this just gets the config in place.
Note: I'm assuming that we'll pick up a change to parso such that
it exposes its type stubs here. Otherwise we'll want to tweak the
imports config to ignore those errors.
2020-07-24 16:10:34 +01:00
Peter Law
480c352d33
Python 3.6 embeddable doesn't have pydoc_data
...
This reinstates the import check for pydoc_data for now.
Specifically I looked in the following:
- python-3.6.8-embed-amd64.zip: missing pydoc_data
- python-3.7.8-embed-amd64.zip: present
- python-3.8.5-embed-amd64.zip: present
2020-07-24 16:07:48 +01:00
Peter Law
b651c6541a
Configure travis' flake8 call more explicitly
...
I'm basing this on '{posargs:jedi}' looking like it was a tox thing,
which we're no longer using.
2020-07-21 23:15:20 +01:00
Peter Law
403564315c
Reflow test to ensure trailing space is preserved
...
Many editors strip trailing space, so avoid using a multiline
string where the space is actually needed.
2020-07-21 22:44:43 +01:00
Peter Law
5e6138d16f
Update to flake8 3.8.x
...
In particular this improves support for detecting usage of various
type annotation usages and adds support for correctly parsing
type: ignore comments which contain a reason tag.
2020-07-21 21:34:58 +01:00
Peter Law
6ef18bea50
Make this noqa more specific
2020-07-21 21:34:37 +01:00
Peter Law
9505dabfef
Reflow for linting
2020-07-21 21:32:22 +01:00
Peter Law
4783c065da
Configure editors for uniform whitespace handling
2020-07-21 21:26:46 +01:00
Peter Law and Dave Halter
f72adf0cbc
Switch to much simpler solution for preserving unbound type vars
...
Co-Authored-By: Dave Halter <davidhalter88@gmail.com >
2020-06-26 11:23:35 +01:00
Peter Law
5184d0cb9c
Support passing values through decorators from factories
...
This builds on the approach taken in https://github.com/davidhalter/jedi/pull/1613
but applies it to type vars themselves so that their type var
nature is preserved when a function returns Callable[[T], T] and
the T has an upper bound.
2020-06-26 11:22:19 +01:00
Peter Law
2d0258db1a
Add tests for class-style decorator factories
2020-06-26 11:19:51 +01:00
Peter Law
3488f6b61d
Add Python 3.8 to the tox env list ( #1618 )
2020-06-20 16:18:32 +02:00
Peter Law
7e637c5e5e
Python 2 compatible super()
2020-06-14 16:27:39 +01:00
Peter Law
4f11f20e1d
Add a signature check for decorated functions
...
Specifically where the decorator is type annotated.
2020-06-14 16:24:42 +01:00
Peter Law
1f082b69d2
Handle passing functions and classes through a TypeVar
...
This fixes #1425 and #1607 by persisting the original underlying
function or class when we process a TypeVar they are passed into.
2020-06-13 23:28:20 +01:00
Peter Law
c62cbd6654
Explicitly handle a not in b operator comparison
...
This avoids a `KeyError` from operator_to_magic_method lookup for
this case. Jedi probably could check for `__contains__` here, however
as it doesn't do so for `in` checks I'm following that lead for now.
Fixes https://github.com/davidhalter/jedi/issues/1594 .
2020-05-23 12:49:53 +01:00
Peter Law
c36904d983
Support custom managers in Django models
...
For the moment this support is limited to just Model.objects
replacements and does not use the custom manager for ForeignKey
related managers.
2020-05-22 12:33:03 +01:00
Peter Law
669b70b2cd
Validate instance methods on Django models
2020-05-22 12:32:14 +01:00
Peter Law
b7cdec427e
Support OneToOneFields
2020-05-18 22:19:20 +01:00
Peter Law
df66b35444
Support UUIDFields
2020-05-18 22:11:31 +01:00
Peter Law
cd9f2f31ea
Support URLFields
2020-05-18 22:10:48 +01:00
Peter Law
b54d7433c7
Support GenericIPAddressFields
2020-05-18 22:10:09 +01:00
Peter Law
43806f8668
Add support for generic optional parameters ( #1559 )
...
* Add support for generic optional parameters
* Tests for passing non-optional arguments to optional parameters
* Remove now-redundant is_class_value handling
This parameter has since been removed from infer_type_vars methods,
much simplifying the code.
2020-05-15 19:56:03 +02:00
Peter Law
55facaaf3d
Switch back to using execute_annotation
...
get_annotated_class_object is (sort-of) the inverse of execute_annotation,
so adding a get_annotated_class_object to implement execute_annotation
specifically for Tuples didn't make much sense.
2020-04-26 14:39:39 +01:00
Peter Law
17ca3a620f
Merge branch 'master' into fix-nested-tuple-argument
2020-04-26 13:56:14 +01:00
Peter Law
8c3fd99009
Tell sith that goto_assignments is now goto
2020-04-26 02:15:53 +02:00
Peter Law
612fd23777
Support accessing the py__class__ of a NewType
...
The test here is a bit contrived, the actual place I found this
was in using a NewType as a type within a NamedTuple. However due
to https://github.com/davidhalter/jedi/issues/1560 that currently
also fails for other reasons. This still feels useful to fix on
its own though.
2020-04-26 00:59:07 +01:00
Peter Law
c19c13e2c6
Apply tuple-only filtering to apply more broadly
2020-04-24 16:44:25 +01:00
Peter Law
891383f8dc
Use get_annotated_class_object over execute_annotation
2020-04-24 16:32:00 +01:00
Peter Law
ce1ac38cde
Implement get_annotated_class_object for Tuples
2020-04-24 16:25:19 +01:00
Peter Law
df951733cd
Rename variable to placate mypy
2020-04-24 12:45:05 +01:00
Peter Law
343a10d491
Drop redundant blank line
2020-04-19 14:42:57 +01:00
Peter Law
72c52f5f15
Add type match guard
2020-04-19 14:29:44 +01:00
Peter Law
cfa01d3ac5
Add handling of nested generic tuples
2020-04-19 14:10:03 +01:00
Peter Law
f8e7447d35
Add handling of nested generic callables
...
Previously tests for these were passing somewhat by accident,
however this commit's parent adds a case which showed that the
handling was missing.
Note that this also relies on the recent fix for nested tuples
which changed the `isinstance` check in `define_generics`.
2020-04-19 13:27:06 +01:00
Peter Law
2ac806e39f
Add test which demonstrates incomplete generic Callable handling
2020-04-19 13:25:02 +01:00
Peter Law
7ebbf9da44
Make this test case obey typing rules in Python
...
Unfortunately I can't recall exactly what it was that this test
case was trying to validate, however on a second look it turns
out that it was working by accident and did not represent a valid
use of generic type vars in Python (which cannot be used completely
unbound as this was).
2020-04-18 22:59:20 +01:00
Peter Law
1c4a2edbdb
Fix construction of nested generic tuple return types
...
Unfortunately this appears to show up a separate bug.
2020-04-18 19:43:47 +01:00
Peter Law
eac5ac8426
Update comment after refactor moved code
2020-03-25 22:35:12 +00:00
Peter Law
7e9ad9e733
Fix typo
2020-03-25 22:32:53 +00:00
Peter Law
e2090772f3
Push tuple handling onto Tuple class
...
This resolves a TODO to avoid using a private method
2020-03-22 16:04:39 +00:00
Peter Law
525b88e9f1
Simplify early-exit code by having it once
2020-03-22 15:49:31 +00:00
Peter Law
3c90a84f68
Extract common get_generics() calls
...
These no longer need to be guarded by the conditions now that we
know these types are generic anyway.
2020-03-22 15:47:46 +00:00
Peter Law
ea33db388b
Remove dict merging where it doesn't do anything
...
These cases are all at the end of a single-path branch that ends
up "merging" against an empty mapping which is then returned
unchanged.
2020-03-22 15:45:18 +00:00
Peter Law
f68d65ed59
Push much looping and merging of infering type vars into ValueSet
2020-03-22 15:29:11 +00:00
Peter Law
3c7621049c
Extract annotation inference onto annotation classes
...
This removes the _infer_type_vars util in favour of a polymorphic
implementation, removing the conditional checks on the type of
the annotation instance.
While for the moment this creates some circular imports, further
refactoring to follow should be able to remove those.
2020-03-22 15:29:11 +00:00
Peter Law
dd60a8a4c9
Extract nested function which is going to be used elsewhere
2020-03-22 15:20:58 +00:00
Peter Law
5bd6a9c164
Rename function which is going to be used elsewhere
2020-03-22 15:18:41 +00:00
Peter Law
c743e5d9f3
Push type check into helper
2020-03-22 15:14:01 +00:00
Peter Law
5ca69458d4
Add testing for mismatch cases
...
This should help catch any errors in our handling of invalid cases.
While some of these produce outputs which aren't correct, what
we're checking here is that we don't _error_ while producing that
output.
Also fix a case which this showed up.
2020-03-22 15:10:43 +00:00
Peter Law
95b0cdcb5e
Add test for child of specialised generic
2020-03-18 22:15:32 +00:00
Peter Law
0f8e7b453e
Formatting
2020-03-18 22:12:21 +00:00
Peter Law
da9d312185
Remove redundant attribute check
2020-03-12 22:06:13 +00:00
Peter Law
b198434694
Remove resolved TODO
...
The common logic this refers to has now been extracted (see 95cec459 )
and the remaining checks are specific to tuple handling.
2020-03-07 20:29:14 +00:00
Peter Law
d06efd0dd1
Push fetching of generics into nested function
...
This slightly simplifies both the calling code and semantics of
the nested function.
2020-03-07 18:09:20 +00:00
Peter Law
96132587b7
Clarify generic tuple inference
...
This hoist a loop invariant conditional check outside the loop
making it clearer and one branch more obviously similar to the
general type handling.
2020-03-07 17:35:29 +00:00
Peter Law
5d273f4630
Explain these branches
2020-03-07 17:35:03 +00:00
Peter Law
95cec459a8
Extract nested function for common pattern
...
This slightly simplifies the code, as well as providing a place
to put an explanation of what the moved block of code does.
2020-03-07 17:06:22 +00:00
Peter Law
3b4fa2aa9c
Clarify variable name
2020-03-07 16:32:38 +00:00
Peter Law
54e29eede1
Add explanation of the parameters to _infer_type_vars
2020-03-07 16:31:12 +00:00
Peter Law
30738a092b
Update sith's module docstring to match the available operations
2020-02-24 01:33:46 +01:00
Peter Law
f1a9e681ad
Ensure comprehensions and generator expressions work
2020-02-23 15:25:28 +00:00
Peter Law
f4cbf61604
Ensure variadic tuples (Tuple[T, ...]) behave like sequences
2020-02-23 14:00:39 +00:00
Peter Law
5e990d9206
Support passing through values for non-annotated tuples
2020-02-23 14:00:16 +00:00
Peter Law
80db4dcf56
Add test to ensure unions work
2020-02-23 14:00:16 +00:00
Peter Law
e557129121
Remove check which doesn't seem to be needed
...
I'm not sure why I added this, though removing it doesn't seem to
casue any issues. I suspect there might be some oddness if the type
being passed in doesn't match the type expected, though them having
the same number of generic paramters isn't an expecially great way
to validate that.
2020-02-23 14:00:16 +00:00
Peter Law
c15e0ef9b8
Ensure specialised types inheriting from generics work
2020-02-23 14:00:15 +00:00
Peter Law
e455709a31
Add test case for nested generic callables
2020-02-23 14:00:13 +00:00
Peter Law
c03ae0315e
Make nested Type[T] annotations work
2020-02-23 13:59:44 +00:00