Skip to content
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 code base to Python 3 #741

Merged
merged 9 commits into from
Apr 29, 2023
Merged

Upgrade code base to Python 3 #741

merged 9 commits into from
Apr 29, 2023

Conversation

maximlt
Copy link
Member

@maximlt maximlt commented Apr 16, 2023

Fixes #703

I ran pyupgrade on the code base to upgrade it to Python 3.7, and then manually made some other upgrades. Notable changes include:

  • Added watch and on_init keywords to the signature of depends
  • Deprecated param.as_unicode
  • Deprecated param.is_ordered_dict

Edit:

  • Added warn keyword to the signature of param_union

@maximlt maximlt requested a review from jlstevens April 16, 2023 21:17
param/ipython.py Outdated
@@ -168,7 +160,7 @@ def _build_table(self, info, order, max_col_len=40, only_changed=False):
readonly = 'RO' if p.readonly else 'RW'
allow_None = ' AN' if hasattr(p, 'allow_None') and p.allow_None else ''

mode = '%s %s%s' % (constant, readonly, allow_None)
mode = '{} {}{}'.format(constant, readonly, allow_None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f-strings seem nicer.

Copy link
Contributor

@jlstevens jlstevens Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Should probably one of those tools that automatically update to f-strings over the codebase. Looks to me like pyupgrade used this style throughout...

@jlstevens
Copy link
Contributor

Looks mostly like I would expect though I would definitely prefer f-strings everywhere. Currently it is removing all the %s format strings and replacing it with a style that isn't that much better imho.

@maximlt
Copy link
Member Author

maximlt commented Apr 17, 2023

Agreed, pyupgrade is on purpose a little shy about upgrading to strings not to mess with the formatting. I've updated .format() to f-strings where I thought it made sense in 2a97492.

@hoxbro
Copy link
Member

hoxbro commented Apr 25, 2023

I get some more string conversion if I use Ruff: ruff param --select="UP" --fix --target-version=py37

@maximlt
Copy link
Member Author

maximlt commented Apr 29, 2023

I've applied the suggested ruff command.

@maximlt maximlt merged commit 866b18f into main Apr 29, 2023
@maximlt maximlt deleted the upgrade_code branch April 29, 2023 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop support of Python 2.7 and 3.6 for Param 2.0
4 participants