Giter Club home page Giter Club logo

Comments (11)

pmiddend avatar pmiddend commented on May 30, 2024 1

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.

pmiddend avatar pmiddend commented on May 30, 2024

I'd at least like to get this exception fixed and have the rest of my code analyzed "in peace".

from crosshair.

pschanely avatar pschanely commented on May 30, 2024

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.

pmiddend avatar pmiddend commented on May 30, 2024

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.

pschanely avatar pschanely commented on May 30, 2024

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.

pmiddend avatar pmiddend commented on May 30, 2024

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.

pschanely avatar pschanely commented on May 30, 2024

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.

pschanely avatar pschanely commented on May 30, 2024

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.

pmiddend avatar pmiddend commented on May 30, 2024

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.

pschanely avatar pschanely commented on May 30, 2024

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.

pschanely avatar pschanely commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.