[MRG+1] Rename isbinarytext function to binary_is_text for clarity #1851
Conversation
Current coverage is
|
return any(c in _BINARYCHARS for c in text) | ||
if not isinstance(data, bytes): | ||
raise TypeError("data must be bytes, got '%s'" % type(data).__name__) | ||
return any(c in _BINARYCHARS for c in data) |
kmike
Mar 7, 2016
Member
docs say this function returns True if there are no control characters, but this function does the opposite
docs say this function returns True if there are no control characters, but this function does the opposite
nyov
Mar 7, 2016
Author
Contributor
So I actually forgot to change the function body and test... facepalm
Thanks for the thorough look.
So I actually forgot to change the function body and test... facepalm
Thanks for the thorough look.
@@ -73,16 +73,16 @@ def noncached(self): | |||
|
|||
class IsBinaryTextTest(unittest.TestCase): |
kmike
Mar 7, 2016
Member
It is better to rename the test case as well.
It is better to rename the test case as well.
7e86bf5
to
99c48b5
Okay I think I got it now. Let me know if there are any other issues or nitpicks (I don't usually run any pep8 style checker). |
"""Return True if the given text is considered binary, or False | ||
otherwise, by looking for binary bytes at their chars | ||
""" This function has been removed. | ||
Please use scrapy.utils.python.binary_is_text """ |
kmike
Mar 7, 2016
Member
I wonder if we should note binary_is_text
does the opposite of isbinarytext
in a docstring. On one hand, this is easy to check in source code; on the other hand, function names look too similar, it is easy to make a mistake and think the function was renamed.
I wonder if we should note binary_is_text
does the opposite of isbinarytext
in a docstring. On one hand, this is easy to check in source code; on the other hand, function names look too similar, it is easy to make a mistake and think the function was renamed.
nyov
Mar 8, 2016
Author
Contributor
I had considered it. But I wasn't sure if the old function doc string would get checked by anyone (unless checking the source and then it should be obvious), and adding a note to the new function doc about an unrelated function would seem strange as well.
I'll add a note to the old one.
I had considered it. But I wasn't sure if the old function doc string would get checked by anyone (unless checking the source and then it should be obvious), and adding a note to the new function doc about an unrelated function would seem strange as well.
I'll add a note to the old one.
Hope that doc string text makes sense. I'll take anything that might sound better. |
""" This function has been removed. | ||
Please use scrapy.utils.python.binary_is_text, which was created to be more | ||
clear about the functions behavior: it is behaving inverted to this one. """ | ||
return not binary_is_text(text) |
nyov
Mar 17, 2016
Author
Contributor
@kmike: when you find the time, let me know if this updated docstring fits as a description?
Or anyone else actually, who might feel like replying.
I didn't really find the perfect wording (could sound less ugly), any alternatives welcome.
@kmike: when you find the time, let me know if this updated docstring fits as a description?
Or anyone else actually, who might feel like replying.
I didn't really find the perfect wording (could sound less ugly), any alternatives welcome.
lopuhin
Mar 17, 2016
Member
@nyov I like the docstring. Just one nitpick: perhaps it's better to change "This function has been removed" into "This function is deprecated", since it is not removed yet.
@nyov I like the docstring. Just one nitpick: perhaps it's better to change "This function has been removed" into "This function is deprecated", since it is not removed yet.
nyov
Mar 17, 2016
Author
Contributor
Indeed, I'll reword that. Thank you
Indeed, I'll reword that. Thank you
See #1389
Since this suggested rename seemed to have positive responses, here is a PR which does just that, to resolve the issue.