100 Commits
Author SHA1 Message Date
Peter Law 83545bc9ec Include a link to the docs in the package metadata 2023-09-22 21:33:52 +01:00
Peter Law 57e7b83455 Add missing import
I suspect this got lost in a merge somewhere, probably the
combination of 7e533ca7e1 and the
Python 3.12 work in a60fdba1d4.
2023-09-22 21:29:31 +01:00
Peter Law 7e533ca7e1 Drop redundant conditional skips for unsupported Python versions 2023-09-17 18:38:12 +01:00
Peter Law a60fdba1d4 Adjust for change to documention change of next in Python 3.12
The signature of the builtin isn't actually changing in Python 3.12,
however its documentation has changed.
2023-09-17 18:27:53 +01:00
Peter Law 770cdade00 Claim support for Python 3.12 2023-09-16 21:41:06 +01:00
Peter Law 29890c1f29 Ignore linux-only os.CLONE_* constants in Python 3.12 in import test 2023-09-16 21:41:06 +01:00
Peter Law 159566e1a0 Add Python 3.12 as a tested platform 2023-09-16 21:41:06 +01:00
Peter Law a80618a2df Unpin Django in tests
It's not completely clear why this was pinned originally, though
at the time Jedi supported Python 2.7 as well as 3.5-3.8, so that
may have had something to do with it.

Removing this pin now seems to work in CI and unblocks some issues
we're seeing around Python 3.12 (specifically that Django<3.1
implicitly relies on distutils, which is no longer available by
default, and possibly other issues).
2023-09-16 21:40:34 +01:00
Peter Law 4bc1b6ef99 Bump use of actions/checkout to avoid Node JS deprecations 2023-09-16 18:12:28 +01:00
Peter Law d655d65d3a Fix typo in comment 2023-09-16 18:03:56 +01:00
Peter Law a28bd24bef Merge branch 'importlib-metadata-entry-points' 2023-05-28 12:08:09 +01:00
Peter Law 54cb64292c Support importlib.metadata entry points for newer python
pkg_resources is deprecated and liable to be dropped at some point.
2023-05-28 11:48:19 +01:00
Peter Law c137eb6918 Modernise importlib usage
`find_module` is deprecated in all supported version of Python and
is slated for removal in the upcoming 3.12. Happily it seems we
can move to the related `find_spec` and just hoist the loader from
the spec which that returns. (This is mostly what current `find_module`
implementations do anyway).
2023-05-27 22:03:51 +01:00
Peter Law d67facc922 Merge branch 'update-github-actions' 2023-05-27 22:03:03 +01:00
Peter Law b5120cc90b Update GitHub Actions for Node 16 support 2023-05-27 00:18:38 +01:00
Peter Law 483e78993d attrs' frozen decorator also acts like a dataclass
In 23.1.0 (specifically in https://github.com/python-attrs/attrs/commit/46053d703d99a6e7419fd291cbf546340690d69d)
the definition of the `frozen` decorator was tweaked slightly, such
that its type stub is separate from that for `define`. This means
that Jedi needs to be told about it as a separate member.

I've manually checked that this still works with the prior version
of `attrs`.

Fixes https://github.com/davidhalter/jedi/issues/1929
2023-05-27 00:13:55 +01:00
Peter Law 3dbcd2c6de Whitespace 2023-05-27 00:10:00 +01:00
Peter Law ca36fcfa4b Fix typo in comment 2023-05-26 21:38:42 +01:00
Peter Law aae2a8e3ed Cope with Windows virtualenvs different casing 2023-02-13 20:25:31 +00:00
Peter Law 67e0bec597 Support Python 3.11
This adds support for targetting Python 3.11 via picking up the
latest grammar from parso while also validating support for running
on 3.11 by adding it to the CI matrix.
2023-02-13 19:58:35 +00:00
Peter Law c71e06fcb3 Clarify that this is also the latest flake8 version which supports 3.6 2023-02-13 19:57:38 +00:00
Peter Law bbd5bcf3ca Merge branch 'update-mypy' 2023-02-13 19:57:20 +00:00
Peter Law 83d0e23800 Type check setup.py too now we can 2023-02-13 19:40:16 +00:00
Peter Law dc4e48d7c7 Be stricter about mypy needing error codes
These make it clearer what's being ignored and harder to
accidentally ignore more than expected.
2023-02-13 19:40:16 +00:00
Peter Law 664b10a5c6 Update mypy to the latest
This includes updating the ignore comments for things which mypy
now knows about or now complains about, as well as pulling in some
typeshed packages for things outside the standard library.
2023-02-13 19:40:16 +00:00
Peter Law 36a4b7d48c Update flake8 and fix issue found 2023-02-13 19:15:35 +00:00
Peter Law b6f761f13c Make typed decorators work for instance methods
This feels incomplete when compared to FunctionMixin.py__get__,
however seems to work at least in the cut-down reported.

Fixes https://github.com/davidhalter/jedi/issues/1801.
2021-12-12 18:18:55 +00:00
Peter Law 72cf41f4c9 Lambdas in comprehensions need parentheses in Python > 3.8
Fixes https://github.com/davidhalter/jedi/issues/1824.
2021-12-12 18:17:53 +00: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 ab2eb570a8 Use search_ancestor for a more robust search 2021-07-24 17:27:27 +01:00
Peter Law aa265a44e1 Have all py__file__ methods return a Path 2021-07-24 17:14:25 +01:00
Peter Law 25a3e31ca8 Add a __repr__ 2021-07-24 17:12:34 +01:00
Peter Law 87388ae00f Drop dead line 2021-07-24 17:12:34 +01:00
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 6787719c28 Ensure *args, **kwargs lookthrough works at module scope too
This means that passthrough signatures will be found for top level
functions, which is useful both where they're wrappered by
`functools.wraps` or not.

Fixes https://github.com/davidhalter/jedi/issues/1791.
2021-07-24 16:58:34 +01:00
Peter Law bb40390225 Add identifiers to these test strings
This makes it easier to work out which one fails when pytest
reports a failure. Mostly useful when introducing failing tests,
which I'm about to do.
2021-07-24 16:15:41 +01:00
Peter Law 0d15347210 Remove confusing comment
I'm assuming that this is incorrect given that there _are_ arguments
where the comment suggests there aren't any.
2021-07-24 16:14:20 +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 LawandDave 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 LawandGitHub 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 LawandGitHub 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 LawandDave Halter 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