Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
A hodgepodge of Py3 & style fixes.#10793
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Looks good other than the Py3.5 pathlib question.
with open(os.path.join(image_path, | ||
'matplotlib.png'), 'rb') as fd: | ||
self.write(fd.read()) | ||
image_path = Path(rcParams["datapath"], "images", "matplotlib.png") |
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'm a little confused about pathlib now. Will this work on 3.5? I wouldn't pick on it, but the test coverage of this PR is not good, so...
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.
Yes, pathlib is 3.4+ (https://docs.python.org/3/library/pathlib.html) ({read,write}_{text,bytes} is 3.5+,https://docs.python.org/3/library/pathlib.html#pathlib.Path.read_bytes).
What changed in 3.6 is that a bunch of stdlib functions that were previously only accepting string paths (open, os.path.*, etc.) started to also accept Path objects (https://www.python.org/dev/peps/pep-0519/), thus greatly decreasing the friction when using Path objects. But that's not something we can rely on (yet).
There are quite a few places where we use the old idiom (e.g.)with open(...) as file: ... = file.read()
which could trivially be replaced byPath(...).read_text()
; I didn't change them (the gain is admittedly limited in that case), but only those where we also do path manipulations (because working on Path objects forthat is much nicer than using os.path, IMO) (or where we do this multiple times in a row).
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.
OK, and I take it nothing trivial can be done to increase the test coverage?
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.
Probably not? If that makes you really uncomfortable I can revert that change, just let me know.
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.
No, I trust you, just asking in case you felt guilty about it...
PR Summary
PR Checklist