Skip to content

Remove future as a dependency#1082

Merged
rmjarvis merged 13 commits into
masterfrom
no_future
Jun 12, 2020
Merged

Remove future as a dependency#1082
rmjarvis merged 13 commits into
masterfrom
no_future

Conversation

@rmjarvis
Copy link
Copy Markdown
Member

@rmjarvis rmjarvis commented May 15, 2020

This is a bit of a "spring cleaning" PR.

I've come to realize that our python usage has very few bits that require the future module, so I'm inclined to remove it as a dependency. Here are the places where we are currently using future and my proposed (via this PR) changes:

  1. basestring: I found a cute way to define basestring that works in both 2 and 3: basestring = ("".__class__, u"".__class__, b"".__class__). This captures str, unicode and bytes properly on both. I put this in utilities.py and import from there when we want it.
  2. exec_: Turns out the python 3 version of exec works just fine in python 2.7. I think the future.exec_ workaround must have been for python 2.6, which we don't support anymore. So I just switched exec_ -> exec, and it works fine.
  3. iteritems, itervalues, iterkeys: These have only ever been an efficiency difference between python 2 and 3, and a minuscule one for all of our uses. So I just switched them all to the regular items, values, keys.
  4. range, zip: Similarly, the difference was just (slight) efficiency. Just use the regular ones in both now.
  5. object: I'm pretty sure this was already not needed. I think object in 2.7 is already the python 3 version.
  6. int: Our usage didn't care about the differences in functionality here, so I just use the native int in both and it's fine.
  7. input: In python 2, this was called raw_input. Easy to handle with a try/except NameError. Just used in galsim_download_cosmos.py.
  8. super: Python 2 doesn't have the no-argument version. It's a little bit of extra typing, but I converted our uses of that to the more verbose one that works in both 2 and 3. This was only being used in errors.py.

@rmjarvis rmjarvis added this to the v2.3 milestone May 15, 2020
@rmjarvis rmjarvis added build Related to compiling, building, installing cleanup Non-functional changes to make the code better labels May 15, 2020
@rmjarvis
Copy link
Copy Markdown
Member Author

rmjarvis commented Jun 9, 2020

Anyone care about this? There no real code changes here, so if no one objects, I'll merge Friday.

@rmjarvis rmjarvis merged commit d461a03 into master Jun 12, 2020
@rmjarvis rmjarvis deleted the no_future branch June 12, 2020 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Related to compiling, building, installing cleanup Non-functional changes to make the code better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant