Repository navigation
Flake8 all the things - #974
dorianpula wants to merge 16 commits into
Conversation
|
Thanks again for tackling this! So excited. Wishing in retrospect I'd had you start on the 1.17 or 1.18 branch, but nbd - this is the lion's share of the work - I can take care of trying to backport (or just...not...rolling forwards is a thing.) |
|
Rebasing to 2.0 locally, going beyond that seems a fool's errand. Then layering more modern/house style on top, mostly removing backslash line continuations in favor of parentheticals. |
|
Also had to tweak flake8 version to work on 2.6...still waiting to see if that is enough to please the Travis gods. |
| maj_status = m.get_int() | ||
| min_status = m.get_int() | ||
| err_msg = m.get_string() | ||
| lang_tag = m.get_string() # we don't care! |
There was a problem hiding this comment.
I guess this can be dropped because an exception is immediately raised?
(It's worth pointing out the non-whitespace changes for a more careful review.)
| self.transport._log( | ||
| WARNING, | ||
| 'Auth rejected because the client attempted to change ' | ||
| 'username in mid-flight') |
There was a problem hiding this comment.
In some projects it's allowed to exceed the line-length for log messages and the like, so that if you e.g. grep for something like "change username in mid-flight" after seeing it in a log line, you find it.
| def _parse_userauth_banner(self, m): | ||
| banner = m.get_string() | ||
| self.banner = banner | ||
| lang = m.get_string() |
There was a problem hiding this comment.
just pointing out another not-just-whitespace change (which is probably OK)
(but you can't always drop m.get_string() when the result is unused, because it mutates m)
There was a problem hiding this comment.
Yea this feels like an oops to me, I think probably best to be consistent with the change in kex_gss.py, where we just do a discarded m.get_string().
| return ret | ||
|
|
||
| def __delitem__(self, key): | ||
| pass # Needed for instantiating HostKeys. |
There was a problem hiding this comment.
a minor functional change here - previously an exception would be thrown if the key was not found, now it won't
There was a problem hiding this comment.
Yea we couldn't figure out what the heck was going on with the original change (happened in the Python 3 shakeup). Originally we just nuked it but I guess Dorian found it was added on purpose. I don't really see why we couldn't make it actually do del self[key] tho...
| min_status = m.get_int() | ||
| err_msg = m.get_string() | ||
| lang_tag = m.get_string() # we don't care about the language! | ||
| m.get_string() # we don't care about the language! |
There was a problem hiding this comment.
interesting that unused m string was handled differently here (even though it also immediately raises an exception)
| :see: : `.ssh_gss` | ||
| """ | ||
| UseGSSAPI = False | ||
| GSSAPICleanupCredentials = False |
There was a problem hiding this comment.
this is an odd one - also set in a test and an example, but never used anywhere (removal looks correct)
There was a problem hiding this comment.
If it's set in test and example but not a functional API member, should probably nuke from those latter as well.
| self.__transport._log( | ||
| ERROR, | ||
| 'Exception in subsystem handler for "{}": {}'.format( | ||
| self.__name, e)) |
There was a problem hiding this comment.
a format style change, uncommon in this PR
There was a problem hiding this comment.
But not a bad change IMHO, {} > %s.
| ) | ||
|
|
||
| return size | ||
| return file_size |
There was a problem hiding this comment.
... in fact it's just extraneous, the real return is above in the with: context. if that fails, an exception will be thrown. this return will never be hit
(but it's fine to just appease flake8 for now)
There was a problem hiding this comment.
I'd rather just nuke it now that we've figured that out, tbh :D
|
|
||
| # can not rewrite this to deal with E721, either as a None check | ||
| # nor as not an instance of None or NoneType | ||
| if fileobj is not type(None): # noqa |
| raise Exception('unknown type for ' + repr(item) + ' type ' + repr(type(item))) | ||
| raise Exception( | ||
| 'unknown type for {!r} type {!r}'.format( | ||
| item, type(item))) |
There was a problem hiding this comment.
interesting format style change (looks fine)
| # along with Paramiko; if not, write to the Free Software Foundation, Inc., | ||
| # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
|
|
||
| # flake8: noqa |
There was a problem hiding this comment.
a bunch of changes were made below to appease flake8, is this a leftover from partway through the process?
There was a problem hiding this comment.
Yeah, I tried doing Flake8 for this module, and it was just overwhelming. Hence the cop-out and I skipped checking the entire module. A better approach would be to break out some of the deeply nested code into separate functions, but I wanted to concentrate on doing this in a separate PR.
|
Thanks for the post-review, @ploxiln - I admit I took most of it on faith due to size & having been physically present during much of the work 😁 I've replied to most of the inline notes & I'll go through and tidy them all up soon unless somebody else beats me to it. (I supplied a lot of similar post-merge changes yesterday, as well, with lots of style tweaks like removal of most line continuations.) |
|
I did notice your follow-up style changes - they did improve the line-wrapping considerably :) |
|
I was unpleasantly surprised at how many I had to leave in, though, because I honestly couldn't say the alternatives were actually better. Usually indicative of deeper code smells that required more time to truly fix! |
|
Working on those updates now. |
|
Ah, the |
|
OK that's all done now?! Waiting on Travis to agree. |
|
👍 |
|
found bug in b99b234 - should not all be |
|
@bitprophet It looks like Is there anything else I can help with flake8? Or I can jump on something else... |
|
@ploxiln thought I fixed all of those, will double check...EDIT: yup I did miss one, pushed fix, thx! @dorianpula Don't think so, I think this is pretty much licked now! |
|
Looks green ✅ |
Introduce and make sure the Paramiko code passes Flake 8 check.
The setup is similar to what Invoke and Fabric use.
Notes: