-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
Make unique_filename not depend on repr. #560
Conversation
For debugging purposes, when a method is created it needs to be put into a "filename". This filename was generated using `repr(attrs)` however this meant that the filename could change every time the program was loaded depending on the whims of repr. (In particular free functions and lambdas would include ids) This solves the problem by changing the name to be <attrs generated {method} {module}.{qualname}> If it should happen that the name is taken then -2 will be appended and incremented until a free filename is found.
I just tested on some code and this is what the traceback looks like. This is a file with 2 classes called
|
Would you mind adding a test for that (substring check is fine)? And a newsfragment please. 😇 |
All right. Let me know if something else is needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome
Thanks you so much David, this looks great! |
For debugging purposes, when a method is created it needs to be put
into a "filename". This filename was generated using
repr(attrs)
however this meant that the filename could change every time the
program was loaded depending on the whims of repr. (In particular
free functions and lambdas would include ids)
This solves the problem by changing the name to be <attrs generated
{method} {module}.{qualname}> If it should happen that the name is
taken then -2 will be appended and incremented until a free filename
is found.
Fixes #558
I'll wait on a reply as to whether this is more or less what we were looking for before I go through the Pull Request checklist.
Pull Request Check List
This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!
If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing to do.
.pyi
).tests/typing_example.py
.docs/api.rst
by hand.@attr.s()
have to be added by hand too.versionadded
,versionchanged
, ordeprecated
directives..rst
files is written using semantic newlines.changelog.d
.If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!