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

Fix infinite recursion #258

Conversation

markusschmaus
Copy link
Contributor

Code review checklist

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Commit messages are meaningful (see this for details)
  • Tests have been included and/or updated
  • Docstrings have been included and/or updated, as appropriate
  • Standalone docs have been updated accordingly
  • Changelog(s) has/have been updated, as needed (see CHANGELOG.md, no need
    to update for typo fixes and such).

(Inception PR)

This fixes the infinite recursion we are getting when trying to call super suing type(obj). By defining the replacement methods inside a method each replacement is bound to the original class without needing to look it up.

Copy link
Member

@goto40 goto40 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Can you add a small unittest?

@markusschmaus
Copy link
Contributor Author

Most of this PR addresses a problem with python2 which led all tests on my end fail. I added a small test which tests the correct behavior in the case of attrs classes which inherit from each other, which is also fixed in this PR.

@markusschmaus
Copy link
Contributor Author

I fixed this error:

E               ValueError: 

Non keyword-only attributes are not allowed after a keyword-only attribute

Newer versions of attrs (including the one I use) no longer have this restriction. python-attrs/attrs#559

@igordejanovic
Copy link
Member

Thanks @markusschmaus, great work! This looks good to me.

With this change we can publish this in the next minor release and drop Python 2 in the next major release.

I noticed a leftover docstring so you can remove it. BTW, do you want to clean this branch yourself or should I squash merge?

@markusschmaus
Copy link
Contributor Author

Squash merge sounds great to me

@igordejanovic igordejanovic merged commit 965f508 into textX:igord/postponed-userobj-init-replace-methods May 18, 2020
igordejanovic pushed a commit that referenced this pull request May 18, 2020
Fix infinite recursion on inheriting user-classes + Python 2 support
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

Successfully merging this pull request may close these issues.

None yet

3 participants