Skip to content

Avoid attributes named "self" #301

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

Merged
merged 2 commits into from
Jan 17, 2021

Conversation

jrversteegh
Copy link
Contributor

I'm currently working with an api that uses json:api. This uses a "self" attribute a lot. python-attrs fails to create an init function for this because of a name collision on self. Although self is not a keyword in python, it's probably a good idea to not allow self as an attribute name. Alternatively, you could try to convince the folks developing python-attrs to allow for a self attribute by using a different name for the self parameter internally, like pydantic does.
This is a quick fix to just create a self_ attribute instead.

@dbanty
Copy link
Collaborator

dbanty commented Jan 16, 2021

Disallowing self is a great idea I think, it's certainly treated like a keyword by convention. Could you run black on the code so it passes CI? poetry run task check will run that along with all the other linters and unit tests.

@dbanty dbanty added this to the 0.8.0 milestone Jan 16, 2021
@codecov
Copy link

codecov bot commented Jan 16, 2021

Codecov Report

Merging #301 (63830cf) into main (93723dd) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #301   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           46        46           
  Lines         1348      1353    +5     
=========================================
+ Hits          1348      1353    +5     
Impacted Files Coverage Δ
openapi_python_client/utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 93723dd...63830cf. Read the comment docs.

@dbanty dbanty merged commit 839171e into openapi-generators:main Jan 17, 2021
@dbanty
Copy link
Collaborator

dbanty commented Jan 17, 2021

Awesome, thanks! I plan on including this in the 0.8.0 release which should include your other open PR.

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.

2 participants