-
Notifications
You must be signed in to change notification settings - Fork 13
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
Upgrade flake8 use typedecl 2 #340
Conversation
* tests: added llnl specific tests from getting-started documentation * tests: divided llnl doc tests into subfolder within tests * linting: applied type annotations * tests: Added doc tests with executor parameters * deleted: old folder of slurm/lsf specific tests * getting started doc tests: fixed status callback test * addressing linting * addressing linting
The reason why flak8 was complaining is because of the removal of support for `# type: xyz` style declarations. So convert all those to proper type declarations.
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.
LGTM, thanks
self.kill_flag = False | ||
self.process = None # type: Optional[subprocess.Popen[bytes]] | ||
self.process: Optional[subprocess.Popen[bytes]] = 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.
That's an interesting one - haven't seen that documented as type. Where did you find this?
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.
https://docs.python.org/3/library/subprocess.html#subprocess.Popen
It turns out Popen is a class. You'd think it's something like Open returning a File or, you know, Verb applied to Noun produces Noun, but no.
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.
Ah, sorry, I wasn't clear. Yes, Popen
is a class - but classname[bytes]
is not a syntax I have seen anywhere before.
I found one google hit by now which indicates that the Popen class is marked as generic - wasn't aware of that...
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 see. Well, if you don't put the type parameters, mypy will produce an error. I'm not entirely sure where I found what that parameter is (str/bytes based on whether you open the output streams in text or binary mode), since I can't find a clear statement of that in the official python documentation.
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.
thx, good to know.
flake8 6.0.0 (and corresponding pyflakes) removed support for
# type: abc
, which caused unused import errors. The solution was to change those type declarations to the "proper" format (var: <type> = <value>
).This time on top of main.