Skip to content

Convert to Python 3#1128

Merged
jleveque merged 57 commits intosonic-net:masterfrom
jleveque:support_py3
Nov 15, 2020
Merged

Convert to Python 3#1128
jleveque merged 57 commits intosonic-net:masterfrom
jleveque:support_py3

Conversation

@jleveque
Copy link
Contributor

@jleveque jleveque commented Sep 22, 2020

- What I did

Conform syntax to support Python 3 using 2to3 tool and manual assessment

- How I did it

Using 2to3 tool as well as manual assessment

- How to verify it

Build a Python 3 version of the sonic-utilities package, install and test all applications

NOTE: This cannot currently be done, as sonic-utilities depends on sonic-config-engine and sonic-yang-mgmt, neither of which are we currently building Python 3 versions of.

  • Need Python 3 version of sonic-config-engine
  • Need Python 3 version of sonic-yang-mgmt

@jleveque jleveque self-assigned this Sep 22, 2020
@lgtm-com

This comment has been minimized.

@lgtm-com

This comment has been minimized.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for it in list(D1.keys()):
for it in D1:

Copy link
Contributor Author

@jleveque jleveque Oct 3, 2020

Choose a reason for hiding this comment

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

This will not work. It would need to be:

for it, _ in D1:

I will not make a change like this in this PR. Plus, keeping .keys() makes it clear what the intention is.

Copy link
Contributor

Choose a reason for hiding this comment

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

It will work. I think you are talking about

for it, _ in D1.items():

In reply to: 499074240 [](ancestors = 499074240)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're correct. I misread this one. Everything started blending together after all these changes :)

I will go back through and do a cleanup pass in the future.

Copy link
Contributor Author

@jleveque jleveque Nov 16, 2020

Choose a reason for hiding this comment

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

I have opened a PR to clean up here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for key in list(In.keys()):
for it in In:

Copy link
Contributor Author

@jleveque jleveque Oct 5, 2020

Choose a reason for hiding this comment

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

This will not work. It would need to be:

for it, _ in In:

I will not make a change like this in this PR. Plus, keeping .keys() makes it clear what the intention is.

config/main.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for intf in list(del_intf_dict.keys()):
for intf in del_intf_dict:

Copy link
Contributor Author

@jleveque jleveque Oct 5, 2020

Choose a reason for hiding this comment

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

This will not work. It would need to be:

for intf, _ in del_intf_dict:

I will not make a change like this in this PR. Plus, keeping .keys() makes it clear what the intention is.

config/main.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

list [](start = 28, length = 4)

The same

Copy link
Contributor Author

@jleveque jleveque Oct 5, 2020

Choose a reason for hiding this comment

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

This will not work. It would need to be:

for feature_name, _ in feature_table:

I will not make a change like this in this PR. Plus, keeping .keys() makes it clear what the intention is.

config/main.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

list [](start = 18, length = 4)

The same

Copy link
Contributor Author

@jleveque jleveque Oct 5, 2020

Choose a reason for hiding this comment

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

This will not work. It would need to be something like:

for (_,intf), _ in vlan_member_table:

I will not make a change like this in this PR. Plus, keeping .keys() makes it clear what the intention is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, I did add a space after the comma.

@lgtm-com

This comment has been minimized.

@lgtm-com

This comment has been minimized.

@lgtm-com

This comment has been minimized.

@lgtm-com

This comment has been minimized.

jleveque added a commit to Azure/sonic-build-tools that referenced this pull request Nov 14, 2020
Only test and build Python 3 package of sonic-utilities. Eliminate Python 2 build and do not install Python 2 dependencies.

sonic-net/sonic-utilities#1128 is silently passing all Python 3 unit tests (see output here). Once this PR is merged, then the check build will pass, allowing that PR to merge.
@lgtm-com
Copy link

lgtm-com bot commented Nov 14, 2020

This pull request fixes 8 alerts when merging 0dba073cabd8479f92a446f095c7355795f29841 into 8079558 - view on LGTM.com

fixed alerts:

  • 6 for Variable defined multiple times
  • 2 for Unused local variable

@lgtm-com
Copy link

lgtm-com bot commented Nov 14, 2020

This pull request fixes 8 alerts when merging 800350f into 8079558 - view on LGTM.com

fixed alerts:

  • 6 for Variable defined multiple times
  • 2 for Unused local variable

@jleveque jleveque marked this pull request as ready for review November 15, 2020 00:39
@jleveque jleveque changed the title Support Python 3 syntax Convert to Python 3 Nov 15, 2020
Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants