Comments (11)
I see what you mean. I don't think the error is that bad to read, and neither is the SmtObject
one. And I also realize that my code is a bit of an "outlier" when it comes to Python usage, I suppose. Much reflection and assumptions about internal attributes. I just wanted to try crosshair and that's what I've been working on.
I guess fixing the remaining error comes down to telling crosshair/python what types I really expect in this function, instead of simply Any
. I tried that before, even, but it was pretty difficult.
from crosshair.
I'd at least like to get this exception fixed and have the rest of my code analyzed "in peace".
from crosshair.
Votes help! I'll investigate this one more during the week.
Would love more bugs for other issues you find - thank you for trying it out!
from crosshair.
Thanks for this amazing project. I'll be trying this out some more over the next weeks and give feedback. I'm totally fine with stuff not working, by the way. It's just that I let CrossHair loose on my whole code basically, and it kept on spitting out these error messages so I wan't able to parse what's happening.
from crosshair.
Thanks :)
Added some pretty basic support just now. Would you give it a shot and let me know how it goes? (you can install the HEAD version with pip install git+https://github.com/pschanely/crosshair
)
from crosshair.
Okay, I tried this with my code, and it still gives errors. I'm not sure if they are the same errors as before though. The code is already self-contained and reeeelatively small, so I attached it to this comment. Does this help?
python_schema.txt
from crosshair.
Very much helps, thanks! I think there is also something going with forward type references; I see NameError: name 'ConfigAST' is not defined
in this one. I think I know what's up & should have a fix in the morning.
from crosshair.
Alright! 3eb1ddb should do it. Give it one more try?
Of course, all this just makes CrossHair able to ingest your module; you'll want to add pre/post conditions for it to do something useful.
For instance, if you wanted to harden your typed_dict_to_schema
against a wider variety of possible arguments, you could put a trivial '''post:True''' condition in there to have it find inputs that could break it. (CrossHair does very little with Any
typed arguments, but can find some things)
from crosshair.
Okay, I've tried running the code with post: True
and get the following error now:
I found an exception while running your function.
python_schema.py:146:
| return SchemaBool()
| if t == float:
| return SchemaFloat()
> if "__origin__" in t.__dict__:
| if t.__origin__ == list:
| return SchemaList(typed_dict_to_schema(t.__args__[0]))
| if t.__origin__ == Union:
AttributeError: 'object' object has no attribute '__dict__'
when calling typed_dict_to_schema(t = <object object at 0x7efc3089f600>)
I realize that my code is somewhat gnarly, but this error seems interesting nontheless. Shouldn't there always be a __dict__
for Python objects?
Again thanks for trying to get this to work.
from crosshair.
Interestingly, not all python objects have a __dict__
!
>>> object().__dict__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute '__dict__'
In particular, I think native classes don't. It's also the case for things like strings and ints.
The repr for object
instances isn't very great. I think I'd like to make the CrossHair error here say
when calling typed_dict_to_schema(t = object())
rather than
when calling typed_dict_to_schema(t = <object object at 0x7efc3089f600>)
Just filed #34.
Now, if you work around that issue, you'll likely run into another that is also confusing. A hint I can offer up early is that when CrossHair is emulating a value of a yet-unknown type, that thing will be of type "SmtObject." I'll need to think a little harder about whether I can improve the error there.
from crosshair.
Closing this issue as we've got basic TypedDict support implemented.
But I'd love to hear more about your experience in the form of more bugs, a github discussion, or messages in the gitter chat!
from crosshair.
Related Issues (20)
- Header files are missing from sdist HOT 1
- Neovim LSP Support HOT 5
- "watch""check" return nothing HOT 6
- Unexpected counterexample when indexing a symbolic sequence by a object of unknown type
- Support annotated-types HOT 1
- Better error message when a file can't be imported HOT 1
- Check __return__ is not None
- Do not treat KeyboardInterrupt as an exception in code-under-analysis
- Some easy cases cannot be solved HOT 6
- Support atomic grouping and possessive quantifiers
- Support correct and compilable representation of enum values in the cover/pytest mode HOT 7
- Support pytest.raises Assertion / Exception match parameter when there is a message in exception HOT 1
- Produce the correct import statements for pytest output on cover command HOT 1
- CrossHair is missing symbolic support for `str.split` without arguments
- Support Python 3.12 HOT 1
- Implement true floating point semantics
- Unexpected checking results for functions with/without type annotations HOT 4
- Generic objects, when realized to strings, raise TypeError on concatenation.
- CrosshairInternal error raised when attempting to use symbolic integer as a function HOT 1
- Ensure all isinstance checks account for undecided types
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 crosshair.