Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py5 Attribute errors could provide useful suggestions #224

Closed
hx2A opened this issue Jan 25, 2023 · 7 comments
Closed

py5 Attribute errors could provide useful suggestions #224

hx2A opened this issue Jan 25, 2023 · 7 comments
Assignees

Comments

@hx2A
Copy link
Collaborator

hx2A commented Jan 25, 2023

When I use git and mistype a command, it will guess at what I meant.

$ git stutas
git: 'stutas' is not a git command. See 'git --help'.

The most similar command is
        status
(py5) 21:25 jim@main ~/Projects/ITP/pythonprocessing/py5generator:$ git status
On branch splitsketch
Your branch is up to date with 'origin/splitsketch'.

nothing to commit, working tree clean

py5 could do this also. If my code includes py5.collor(100, 200, 300) it currently responds with AttributeError: py5 has no function or field named collor. What if it instead said it said AttributeError: py5 has no function or field named collor. Did you mean to type "color"?

Originally posted by @hx2A in #198 (comment)

@hx2A
Copy link
Collaborator Author

hx2A commented Jan 25, 2023

Also look at http://norvig.com/spell-correct.html for a simple ago and the Python 3.10 feature for Attribute Errors https://docs.python.org/3.10/whatsnew/3.10.html#attributeerrors

@hx2A hx2A added the good first issue Good for newcomers label Mar 5, 2023
@hx2A hx2A removed the good first issue Good for newcomers label Mar 19, 2023
@hx2A hx2A self-assigned this Mar 19, 2023
@hx2A
Copy link
Collaborator Author

hx2A commented Mar 19, 2023

@villares , I now have a working prototype for this. Here are a few example error messages:

py5 encountered an error in your code:

File "<ipython-input-6-b7441cc777da>", line 2, in setup
    1    def setup():
--> 2        c = py5.colorr(255)
    3        py5.background(c)
    ..................................................
     py5.colorr = # AttributeError
          py5 = <module 'py5' from '/Users/jim/INSTALL/anaconda3/envs/
           py5/lib/python3.8/site-packages/py5/__init__.py'>
    ..................................................

AttributeError: py5 has no function or field named "colorr". Did you mean "color"?
py5 encountered an error in your code:

File "<ipython-input-9-e740f3e4b3eb>", line 2, in draw
    1    def draw():
--> 2        py5.rect(py5.mouse_x, py5.mouse_z, 10, 10)
    ..................................................
     py5.mouse_x = 0
     py5.mouse_z = # AttributeError
          py5 = <module 'py5' from '/Users/jim/INSTALL/anaconda3/envs/
           py5/lib/python3.8/site-packages/py5/__init__.py'>
    ..................................................

AttributeError: py5 has no function or field named "mouse_z". Did you mean "mouse_x" or "mouse_y"?

This has been added to the Sketch class. I can easily add it to the others, such as Py5Graphics, Py5Image, Py5Shape, etc. This will be a helpful feature for beginners!

@hx2A
Copy link
Collaborator Author

hx2A commented Mar 20, 2023

Almost ready to make this PR. It is in good shape, just need to do more testing to verify there are no more needed adjustments. This was harder than I thought it would be.

@villares
Copy link
Collaborator

If you could ping me next weekend I could try building py5 like you instructed me before...

@hx2A
Copy link
Collaborator Author

hx2A commented Mar 24, 2023

If you could ping me next weekend I could try building py5 like you instructed me before...

Sure thing! Do you mean this weekend or next weekend?

I just merged this PR so this feature is now a part of py5.

@hx2A hx2A closed this as completed Mar 24, 2023
@villares
Copy link
Collaborator

I meant this weekend, but it will be a bit busy, so maybe next week or next weekend!

@hx2A
Copy link
Collaborator Author

hx2A commented Mar 25, 2023

I meant this weekend, but it will be a bit busy, so maybe next week or next weekend!

OK! I need to get a fix in for #254 before it makes sense for you to test. I believe I have a solution available, I just need time to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants