-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Clean up syntax for supported Python versions. #1963
Conversation
Ran code through [pyupgrade](https://github.com/asottile/pyupgrade). This is supported in every Python version 2.7+.
No need to specify 0,1.. if paramters are passed in order.
Test PASSed. |
@@ -572,8 +572,8 @@ def extract_code_globals(cls, co): | |||
# PyPy "builtin-code" object | |||
out_names = set() | |||
else: | |||
out_names = set(names[oparg] | |||
for op, oparg in _walk_global_ops(co)) |
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.
Let's not make any changes to this file as it is directly copied from the cloudpickle repository.
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.
Good point. Put in a PR w/cloudpickle to change that though.
python/ray/dataframe/dataframe.py
Outdated
@@ -260,7 +260,7 @@ def __repr__(self): | |||
# The split here is so that we don't repr pandas row lengths. | |||
result = self._repr_helper_() | |||
final_result = repr(result).rsplit("\n\n", maxsplit=1)[0] + \ | |||
"\n\n[{0} rows x {1} columns]".format(len(self.index), | |||
"\n\n[{} rows x {} columns]".format(len(self.index), |
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.
If we do this change (and others) we'll need to fix the indentation of the next line
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 fine leaving this as is then, though I'd prefer that there be a git hook to require all code to be run through auto-formatters. It'd unify things like the use of certain syntax, indent, and quote styles.
@devin-petersohn can you take a look at the changes to the dataframes files and see if these make sense to you? If you prefer we can make these changes only for non-dataframes files. |
@robertnishihara @alok These changes are fine for the dataframes files. Thanks! |
This reverts commit efa5ec8.
Drop use of set literal until cloudpickle uses it.
I think those are both of the necessary changes. |
Test PASSed. |
Looks good, thanks! There are still a couple linting errors at https://travis-ci.org/ray-project/ray/jobs/372891975. Could you fix those? |
We need to set up a git pre-push hook to automatically run this stuff.
I think that's all the lint errors taken care of. |
Thanks @alok, yapf seems to be complaining (though unfortunately it doesn't list the diff).
|
@robertnishihara I ran yapf locally with the same flags and it gave no changes. Travis says the build ran 19 hours ago, so maybe it hasn't picked up the changes yet? |
This should probably be merged after ray-project#1963.
There are still linting errors, can you have another look? |
Maybe it's a version issue with yapf? |
The cloudpickle changes were just merged in, so we can pick them up next time we update those files. |
Closing and reopening a PR apparently forces Travis to rebuild, and the lint test is green now. |
Jenkins test this please |
Test PASSed. |
* magic-methods: fmt Fix IndentationError Write magic methods for SampleBatch/PartialRollout Clean up syntax for supported Python versions. (ray-project#1963) [DataFrame] Implements mode, to_datetime, and get_dummies (ray-project#1956) [DataFrame] Fix dtypes (ray-project#1930) keep_dims -> keepdims (ray-project#1980) add pthread linking (ray-project#1986) [DataFrame] Add layer of abstraction to allow OID instantiation (ray-project#1984) [DataFrame] Fix blocking issue on _IndexMetadata passing (ray-project#1965)
* master: (21 commits) Expand local_dir in Trial init (ray-project#2013) Fixing ascii error for Python2 (ray-project#2009) [DataFrame] Implements df.update (ray-project#1997) [DataFrame] Implements df.as_matrix (ray-project#2001) [DataFrame] Implement quantile (ray-project#1992) [DataFrame] Impement sort_values and sort_index (ray-project#1977) [DataFrame] Implement rank (ray-project#1991) [DataFrame] Implemented prod, product, added test suite (ray-project#1994) [DataFrame] Implemented __setitem__, select_dtypes, and astype (ray-project#1941) [DataFrame] Implement diff (ray-project#1996) [DataFrame] Implemented nunique, skew (ray-project#1995) [DataFrame] Implements filter and dropna (ray-project#1959) [DataFrame] Implements df.pipe (ray-project#1999) [DataFrame] Apply() for Lists and Dicts (ray-project#1973) Clean up syntax for supported Python versions. (ray-project#1963) [DataFrame] Implements mode, to_datetime, and get_dummies (ray-project#1956) [DataFrame] Fix dtypes (ray-project#1930) keep_dims -> keepdims (ray-project#1980) add pthread linking (ray-project#1986) [DataFrame] Add layer of abstraction to allow OID instantiation (ray-project#1984) ...
* master: (25 commits) [DataFrame] Add direct pandas imports for MVP (ray-project#1960) Make ActorHandles pickleable, also make proper ActorHandle and ActorC… (ray-project#2007) Expand local_dir in Trial init (ray-project#2013) Fixing ascii error for Python2 (ray-project#2009) [DataFrame] Implements df.update (ray-project#1997) [DataFrame] Implements df.as_matrix (ray-project#2001) [DataFrame] Implement quantile (ray-project#1992) [DataFrame] Impement sort_values and sort_index (ray-project#1977) [DataFrame] Implement rank (ray-project#1991) [DataFrame] Implemented prod, product, added test suite (ray-project#1994) [DataFrame] Implemented __setitem__, select_dtypes, and astype (ray-project#1941) [DataFrame] Implement diff (ray-project#1996) [DataFrame] Implemented nunique, skew (ray-project#1995) [DataFrame] Implements filter and dropna (ray-project#1959) [DataFrame] Implements df.pipe (ray-project#1999) [DataFrame] Apply() for Lists and Dicts (ray-project#1973) Clean up syntax for supported Python versions. (ray-project#1963) [DataFrame] Implements mode, to_datetime, and get_dummies (ray-project#1956) [DataFrame] Fix dtypes (ray-project#1930) keep_dims -> keepdims (ray-project#1980) ...
* Add flake8 to Travis * Add flake8-comprehensions [flake8 plugin](https://github.com/adamchainz/flake8-comprehensions) that checks for useless constructions. * Use generators instead of lists where appropriate A lot of the builtins can take in generators instead of lists. This commit applies `flake8-comprehensions` to find them. * Fix lint error * Fix some string formatting The rest can be fixed in another PR * Fix compound literals syntax This should probably be merged after #1963. * dict() -> {} * Use dict literal syntax dict(...) -> {...} * Rewrite nested dicts * Fix hanging indent * Add missing import * Add missing quote * fmt * Add missing whitespace * rm duplicate pip install This is already installed in another file. * Fix indent * move `merge_dicts` into utils * Bring up to date with `master` * Add automatic syntax upgrade * rm pyupgrade In case users want to still use it on their own, the upgrade-syn.sh script was left in the `.travis` dir.
What do these changes do?
Replaces syntax with better syntax.
The dict/set/tuple literals (curly braces) for comprehensions and instantiation is
clearer and faster than writing unidiomatic calls to each of those functions.
Related issue number
No.