Comments (6)
Sorry what? You even blurred parts. You have to write a way better issue than this, sorry. You cannot just send screenshots without any real work. Please take half an hour to write up a clear issue. I'm closing, but happy to reopen if you write a better issue.
And: I don't want to see any screenshots, please write text.
from jedi.
ok,the code is simple:
import jedi
kwargs = {
"code": "from dataclasses import dataclass, field\n\n\n@dataclass\nclass struct_5e93e57ca36a6716689ba1d83a962784:\n output: any\n\n@dataclass\nclass struct_0c7779220cb333fccdfe255ddf9ac695:\n outputs: struct_5e93e57ca36a6716689ba1d83a962784 = field(default_factory=struct_5e93e57ca36a6716689ba1d83a962784)\n\n\nStart = struct_0c7779220cb333fccdfe255ddf9ac695()\n\n\nresult = Start.outputs.output\n",
"path": "/Users/bytedance/Library/Application Support/JetBrains/PyCharm2023.3/light-edit/test11.py",
"environment": None,
"project": jedi.Project(path="/Users/bytedance/Library/Application Support/JetBrains/PyCharm2023.3/light-edit/"),
}
code_position = {
"column": 1,
"line": 16
}
definitions = jedi.Script(**kwargs).infer(**code_position)
print(definitions[0].full_name)
the output is builtins.bool instead of any:
<Name full_name='builtins.bool', description='instance bool'>
@davidhalter by the way I have no permission to reopen this issue
from jedi.
I cannot read the code like this. Please post it in a short amount way. According to your Github history you are probably very new to posting issues. This is of course fine. But you have to put yourself into the shoes of the maintainer: How can you post an issue that causes minimum amount of work for the other side? Here for example, I still have no idea what the issue is. I can of course count the characters to 16 to count where your cursor is. But why do I have to do that? Why is there no description? At this point I just assume you are very lazy and are wasting my time. Sorry if this is not the case.
from jedi.
sorry,after fomatter the code like follows:
from dataclasses import dataclass, field
@dataclass
class struct_5e93e57ca36a6716689ba1d83a962784:
output: any
@dataclass
class struct_0c7779220cb333fccdfe255ddf9ac695:
outputs: struct_5e93e57ca36a6716689ba1d83a962784 = field(default_factory=struct_5e93e57ca36a6716689ba1d83a962784)
Start = struct_0c7779220cb333fccdfe255ddf9ac695()
result = Start.outputs.output
the cursor over word "result", Its actual type should be any,but jedi inferred that bool。
I actually have a description of the problem at the top, and I thought you had read it. I'm really sorry
@aivarannamaa
from jedi.
I have identified where this bug is located。
The definition of any Type is:
def any(*args, **kwargs): # real signature unknown
"""
Return True if bool(x) is True for any x in the iterable.
If the iterable is empty, return False.
"""
pass
It has a return type bool
So,when the jedi infers annotation it should have some mechanism to stop continuing recursive types(For example, in method infer_annotations, it is determined that)。Perhaps it's a built-in type whitelist or something else
@aivarannamaa
from jedi.
I actually have a description of the problem at the top, and I thought you had read it. I'm really sorry
No you don't have a description at the top. You have a few very confusing screenshots. A good report looks like this: #1691 In that particular issue I can use the code the user provided and check it. This is not always easily possible, but I'm pretty sure in your case it would have been possible.
At this point I still do not know what any
is. You should also try to create a minimal reproducible example (please read https://stackoverflow.com/help/minimal-reproducible-example). For example I do not want to read something like struct_0c7779220cb333fccdfe255ddf9ac695
. This is incredibly confusing. Just use short names, so I can understand like foo
and bar
or apple
and pear
.
[any] It has a return type bool
Jedi is aimed at autocompletion. For this reason it uses docstrings like Return True if bool(x) is True for any x in the iterable.
and thinks because the docstring has True or bool in it (I'm not quite sure what triggers it), its return type will be a bool. I won't change that. However you can probably just use an annotation like def any(*args, **kwargs) -> Any
to make your intentions clear, which is probably important anyway, because the docstring says something else.
from jedi.
Related Issues (20)
- Completion fails when variable name is identical to type name HOT 4
- 'TreeInstance' object has no attribute 'with_generics' when using typing.Literal["str"] return annotation on property HOT 4
- How to discover the import statement for a particular Name? HOT 4
- Does Jedi support type inference for type annotations that include generics? HOT 2
- _get_executable_path() can't get the correct path on Windows Anaconda
- Issues with pytest 8 HOT 1
- [Feature request] Support for syntax coloring (based on symbol type) HOT 1
- Script.infer() unexpectedly returns empty list HOT 10
- Jedi outputs: Syntax Error Invalid Syntax HOT 2
- [Feature Request]: infer the return type of functions HOT 1
- `test_completion_param_annotations` fails in Python 3.13 HOT 4
- jedi automatic completion missing HOT 9
- Vendored `typeshed` is totally obsolete HOT 1
- Rhs in the form of "x" in "xxx" cannot infer the type HOT 6
- Question: making jedi understand dynamically managed imports HOT 1
- Python 3.13.0b3+ `functools.partial` being a descriptor messes with signatures HOT 1
- Some simple Not expressions cannot infer types HOT 3
- Sort completions so that the one most resembling the typing code comes first HOT 3
- name conflict with builtin modules HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jedi.