Idiomatic type check#1991
Conversation
edc7b89 to
ea9c389
Compare
ea9c389 to
eacae96
Compare
mhammond
left a comment
There was a problem hiding this comment.
It's going to take some time to go through this manually - and the import a plus is None changes make it more difficult. We also need to be careful because isinstance and checking type() == ... have different semantics in the case of subclasses, which will not usually be a problem, but might sometimes.
| dllid may be None, a dll object, or a string with a dll name""" | ||
| # must take a reference to the DLL until InitDialog. | ||
| self.dll = dllFromDll(dllid) | ||
| if type(id) == type([]): # a template |
There was a problem hiding this comment.
isn't this (and the similar change below) wrong?
There was a problem hiding this comment.
I fixed up the PR and removed the changes that shouldn't have been in there. Ready to review :)
|
The import changes should be split off in #1986 I didn't realize this PR still contained them. |
|
@mhammond Even if they both fall under "idiomatic type checks", would you prefer if I split off |
This is the third PR in a series concerning code cleanup. With the final goal to make basic type-checking validation of public methods possible, easing the addition of 3.7+ type annotations.
Noneusingisrather than==isinstance, which is the idiomatic way of type-checking in Python. Type-checkers also support type inference this way.