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

Refactors #44

Merged
merged 3 commits into from Sep 9, 2021
Merged

Refactors #44

merged 3 commits into from Sep 9, 2021

Conversation

tusharsadhwani
Copy link
Contributor

  • use hasattr instead of getattr(..., None) is None
  • Rename TestEventLoopPolicy class so that pytest doesn't warn about not being able to test that class.

@alex-sherman
Copy link
Owner

Thanks for the PR!

Personally I prefer the gettatr method. It would be weird if, for whatever reason, we add _loop member to the class and that breaks it (even though the value is None). I'd request reverting that.

I would also suggest renaming to EventLoopTestPolicy instead to avoid the underscore.

@tusharsadhwani
Copy link
Contributor Author

getattr would also break on an equally unlikely _loop = 42 definition. My humble suggestion would he to consider using more widely understood code instead of optimizing for the fringe None case.

EventLoopTestPolicy sounds good.

@alex-sherman
Copy link
Owner

alex-sherman commented Sep 8, 2021

42 and None are not equally likely, None would be a pretty obvious choice for something that is lazy initialized and was previously the way these fields worked. I don't really see the benefit of the mild cleanup vs. a less robust implementation. Please revert the hasattr change.

@alex-sherman alex-sherman merged commit 88c4ecd into alex-sherman:master Sep 9, 2021
@tusharsadhwani tusharsadhwani deleted the refactors branch September 9, 2021 19:46
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

2 participants