-
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
Conversation
It will still die, just as before, but it now includes a *helpful* error message
@@ -117,4 +123,5 @@ def stop(self): | |||
|
|||
self.active.set() | |||
self.thread.join(self.t + 1) | |||
# noinspection PyAttributeOutsideInit |
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?
vim for me :) I have been meaning to take a linter to the code for a while, which should catch issues like this, too:
|
@@ -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 comment
The 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 comment
The 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 # noinspection PyAttributeOutsideInit
is because of a warning that the class spontaneously acquired a timer
attribute which wasn't mentioned elsewhere in the class; it is unclear what that statement was trying to do, but because I couldn't prove it was wrong, I just asked PyCharm to not warn me (or follow-on coders) about it.
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.
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 __dict__
with a value of None, so it's pretty low impact.
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 comment
The 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 comment
The 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
On Aug 22, 2014, at 17:20, Matthew Daniel [email protected] wrote:
In kafka/util.py:
@@ -117,4 +123,5 @@ def stop(self):
self.active.set() self.thread.join(self.t + 1)
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.# noinspection PyAttributeOutsideInit self.timer = None
The # noinspection PyAttributeOutsideInit is because of a warning that the class spontaneously acquired a timer attribute which wasn't mentioned elsewhere in the class; it is unclear what that statement was trying to do, but because I couldn't prove it was wrong, I just asked PyCharm to not warn me (or follow-on coders) about it.
—
Reply to this email directly or view it on GitHub.
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.
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.
tests pass -- merging! |
In 0.9.2 (and master), if one passes a
group
toSimpleConsumer
that is a unicode string, it bombs with the terribly unhelpful message below. This PR merely makes the error more helpful by providing a message describing what should have happened and what type was provided. With it in place, the fix would be obvious.p.s. If you have not yet tried PyCharm you don't know what you're missing. I'm surprised that unittest2 allows such things, but the
test.test_util.UtilTest
class redeclared the same method name over and over.