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

Remove __nonzero__ methods #384

Merged
merged 1 commit into from
Nov 17, 2022
Merged

Remove __nonzero__ methods #384

merged 1 commit into from
Nov 17, 2022

Conversation

sobolevn
Copy link
Contributor

__nonzero__ is not used in python3.
And since setup.py declares python3.7 support only, I think it is safe to remove these methods.

I found this while working on typeshed types for this project 🙂

@@ -224,13 +222,11 @@ def __len__(self):
else:
return self.strbuf.__len__()

def __nonzero__(self):
def __bool__(self):
# use self.__len__ rather than len(self) FBO of not getting
Copy link

Choose a reason for hiding this comment

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

Presumably we don't need __bool__ either:

>>> class Foo:
...     def __init__(self, x): self.x = x
...     def __len__(self): return self.x
... 
>>> bool(Foo(1))
True
>>> bool(Foo(5))
True
>>> bool(Foo(0))
False

Copy link

Choose a reason for hiding this comment

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

That might have consequences which I am not able to judge.

Skimming the code it seems that now you can have a length FileBasedBuffer instance which is True.
Removing the __bool__ method this will change to False.

But, as said, I am not much in to this code to say if thic can be a good or bad thing.

Copy link

@ale-rt ale-rt left a comment

Choose a reason for hiding this comment

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

LGTM

@digitalresistor digitalresistor merged commit 00812e3 into Pylons:main Nov 17, 2022
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.

4 participants