1
0
forked from VimPlug/jedi
Commit Graph

77 Commits

Author SHA1 Message Date
Dave Halter
6ea5ad7b19 Fix issue around completions with multiple with with_items, fixes 1931 2023-07-27 11:54:39 +02:00
Peter Law
78a95f4751 Handle generics appearing within any quoted annotations
This hoists the solution added for return-type annotations to
also apply for input annotations so they work too.
2021-07-25 16:31:27 +01:00
Peter Law
599a1c3ee1 Handle generics appearing within quoted return annotations
This ensures that these quoted likely forwards references in
return type annotations behave like their non-quoted equivalents.

I suspect there may be other places which will need similar
adjustments, which may mean that we should push the conversion
a layer closer to the parsing (perhaps in `py__annotations__`?).

One case I know that this doesn't solve (but which likely needs
similar adjustment) is generics in return types of comment-style
annotations. They're less likely and may not be worth supporting
since all supported Python versions can use the in-syntax spelling
for annotations at this point.
2021-07-25 15:32:22 +01:00
Peter Law
6814a7336c Hoist common variable for additional re-use 2021-07-25 15:23:51 +01:00
Peter Law
9505dabfef Reflow for linting 2020-07-21 21:32:22 +01:00
Dave Halter
dac1fb0a06 Get rid of a few Python 2 things 2020-07-02 16:00:26 +02:00
Dave Halter
5ab351dc8f Remove unicode literals from code base 2020-07-02 10:43:14 +02:00
Dave Halter
49e4b1a0f8 Remove force_unicode 2020-07-02 01:47:21 +02:00
Dave Halter
4e2ca9e5fd Remove some pickle compatibility 2020-07-02 00:50:58 +02:00
Dave Halter
395f7fc59e Remove inspect.Parameter compatibility 2020-07-02 00:44:25 +02:00
Peter Law
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
Dave Halter
d0270b5e59 DefineGenericBase -> DefineGenericBaseClass 2020-05-10 03:07:40 +02:00
Dave Halter
434866558a Instances should not need get_generics 2020-05-10 02:59:54 +02:00
Dave Halter
42963a0e03 By having get_annotated_class_object for Tuple/Callable, some details are not necessary anymore 2020-05-10 02:52:42 +02:00
Dave Halter
c2d1da09cb Make sure that Tuple/Callable instances have the correct py__class__ 2020-05-10 01:05:55 +02:00
Dave Halter
3b48c76e4a Make a function private 2020-05-09 00:49:37 +02:00
Dave Halter
2a227dcc7a Remove is_class_value from infer_type_vars 2020-05-08 17:49:02 +02:00
Dave Halter
c3fc129695 Fix a small issue 2020-04-12 00:54:31 +02:00
Dave Halter
02c3d651bd Some more code quality fixes 2020-04-11 02:23:23 +02:00
Dave Halter
bdd4deedc1 Some code cleanups 2020-04-11 02:11:52 +02: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
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
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
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
c03ae0315e Make nested Type[T] annotations work 2020-02-23 13:59:44 +00:00
Peter Law
bc53dabce3 Make tuple generic parameters work 2020-02-23 13:59:44 +00:00
Peter Law
969a8f1fd9 First pass at extending infer_type_vars
This mostly works for the new tests, but doesn't work for:
- tuples (though this seems to be because they lack generic information anyway)
- nested Type[T] handling (e.g: List[Type[T]])
2020-02-23 13:59:44 +00:00
Peter Law
6efafb348e Extract the annotation name upfront
We almost always need this and this simplifies the code within
each branch. This also means we'll be able to the name to determine
the branching.
2020-02-22 19:42:08 +00:00
Peter Law
36b4b797c1 Add trailing comma 2020-02-22 19:42:08 +00:00
Dave Halter
7a55484b79 Fix a test issue 2020-02-04 23:56:01 +01:00
Dave Halter
a49c757b8a Make Ellipsis without list in Callable work, fixes #1475 2020-02-03 09:25:46 +01:00
Dave Halter
e656a5f18f Make it possible to infer Callable TypeVars, fixes #1449 2019-12-12 23:46:55 +01:00
Dave Halter
8213d183fb Start using generic managers, for #1413 2019-12-08 21:56:30 +01:00
Dave Halter
df697cfb03 Make AbstractAnnotatedClass private 2019-12-08 19:00:26 +01:00