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

Exclude float("inf") from B008 #154

Closed
erichang-bcad opened this issue Jan 27, 2021 · 6 comments
Closed

Exclude float("inf") from B008 #154

erichang-bcad opened this issue Jan 27, 2021 · 6 comments

Comments

@erichang-bcad
Copy link
Contributor

Currently, using positive/negative infinity as default values for function arguments will trigger B008, as it thinks we're calling the float() function. Unless there are other ways to specify infinities as literals in Python, I think this behavior should be fixed. Thanks.

@cooperlees
Copy link
Collaborator

Yeah I'd accept a fix with that. Should be able to say if function name == float ignore. Please also unittest and comment why this was done for future code visitors. Thanks.

@cooperlees
Copy link
Collaborator

If there is int() or other type equivalents, we might as well cover them too.

@erichang-bcad
Copy link
Contributor Author

I can submit a PR, but I have a few questions about implementation:

  1. do you want to allow calls for int()? In Python, only positive/negative infinities and NaN don't have literals, so you don't need to allow int() if you want to always force users to write out string literals.

  2. do you want a relaxed or strict check? If you want to be strict, you can only allow float() if argument is a string representing infinities or NaN. If you want to be relaxed, you can skip checking the argument of float().

  3. If you want to allow int(), do you want a relaxed or strict check? A strict check will make sure the argument is a string literal (and optionally the base parameter).

@cooperlees
Copy link
Collaborator

I can submit a PR, but I have a few questions about implementation:

  1. do you want to allow calls for int()? In Python, only positive/negative infinities and NaN don't have literals, so you don't need to allow int() if you want to always force users to write out string literals.

Rigthtio. Let's skip int. I wasn't sure if it made sense.

  1. do you want a relaxed or strict check? If you want to be strict, you can only allow float() if argument is a string representing infinities or NaN. If you want to be relaxed, you can skip checking the argument of float().

Hmm - I think it's better to start strict for this edge case. See if anyone else shares a preference. Can always go looser if it makes sense.

  1. If you want to allow int(), do you want a relaxed or strict check? A strict check will make sure the argument is a string literal (and optionally the base parameter).

Ignore since we can skip int in this PR.

Thanks!

@ichard26
Copy link
Contributor

ichard26 commented Mar 9, 2021

Uhhhhhhhhhhhhhhhhhhhh, this is the Close Issues That Should Be But Aren't police here,

PR GH-155 has been merged so yeahhh... hi @cooperlees

(and no I don't regret the overcasualiness I'm using)

@cooperlees
Copy link
Collaborator

Thanks @ichard26

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

No branches or pull requests

3 participants