-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Better type errors #204
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
Better type errors #204
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,22 @@ | |
|
||
|
||
def write_int_string(s): | ||
if s is not None and not isinstance(s, str): | ||
raise TypeError('Expected "%s" to be str\n' | ||
'data=%s' % (type(s), repr(s))) | ||
if s is None: | ||
return struct.pack('>i', -1) | ||
else: | ||
return struct.pack('>i%ds' % len(s), len(s), s) | ||
|
||
|
||
def write_short_string(s): | ||
if s is not None and not isinstance(s, str): | ||
raise TypeError('Expected "%s" to be str\n' | ||
'data=%s' % (type(s), repr(s))) | ||
if s is None: | ||
return struct.pack('>h', -1) | ||
elif len(s) > 32767 and sys.version < (2,7): | ||
elif len(s) > 32767 and sys.version < (2, 7): | ||
# Python 2.6 issues a deprecation warning instead of a struct error | ||
raise struct.error(len(s)) | ||
else: | ||
|
@@ -117,4 +123,5 @@ def stop(self): | |
|
||
self.active.set() | ||
self.thread.join(self.t + 1) | ||
# noinspection PyAttributeOutsideInit | ||
self.timer = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i guess the better question is what does this mean... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We had people on my team who swore by vim as well, because one can manipulate text amazingly well in vim. The trouble is that a Python programmer is not manipulating text, they are paid to manipulate Python code. PyCharm works with code, vim works with text. But it's your project, you can do as you'd like. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a funny thing about Python objects, you can set any attribute you'd like without much complaint. As for this particular assignment, if effective does nothing but create an attribute in the object's I do believe it is vestigial code though, I don't see any other references to "timer" anywhere (like you say) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh and another note: you should never ever mix source code with editor preferences. I mean, really! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's pretty poor form to start an editor flame war in a code review, or to assert that text editing is somehow not also editing code. One could just as easily assert that vim edits code just as well if not better than Pycharm without crippling your ability to edit the text the code is composed of. ;-) -Mark
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree with all of that, but this PR does fix some good stuff. re editors, meh. it's typically just a wrapper on one of the standard linting tools. I opened #205 to get that into our test pipeline, which I think would address the underlying issue here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this comment mean?