Skip to content

Conversation

ashwin9390
Copy link
Contributor

@ashwin9390 ashwin9390 commented Jul 11, 2024

Main ticket CP-49100 :Move python3 scripts from scripts directory to python3 directory.

Sub task CP-49931: mv scripts/xe-reset-networking to python3/bin

Update summary: @psafont asked:

Why is it not worth declaring the variable instead?

@bernhardkaindl added:
@psafont: please check those fixes for it:

Added fixes for pyright unbound variable warnings:

  1. Rework unclean exception handling using a context manager.
  2. Declare address and master in case of an Exception as well.

Fixed a "scary" pylint warning too:

  • Fix warning on unsupported escape sequence using a raw string.
  • Removed python2 warning list from pyproject.toml

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
"""
# pyright: reportPossiblyUnboundVariable=false
Copy link
Member

Choose a reason for hiding this comment

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

Why is it not worth declaring the variable instead?

Copy link
Collaborator

@bernhardkaindl bernhardkaindl Jul 11, 2024

Choose a reason for hiding this comment

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

@psafont, @ashwin9390:

Initially, it was my recommendation to not touch the warnings (disable them) because the script's style is quite old (bad):

Many locations trigger this warning:

The reason was that I did not immediately see a clean way to fix all possibly unbound variable warnings.

The cause for the many unbound variables warnings is that the exception handling wasn't done nicely.

Now, to fix all of them, I had the idea to use a context manager handling it:

  • In case you like it, I've pushed the fixes for pyright now to the PR. Please check!

New commit:

    CP-49931: mv scripts/xe-reset-networking to python3/bin, fix pyright
    
    Fix pyright:
    - Rework unclean exception handling using a contextmanager.
    - Declare address and master in case of an Exception as well.
    - Fix warning on unsupported escape sequence using a raw string.
    
    Signed-off-by: Ashwinh <ashwin.h@cloud.com>
    Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>

@bernhardkaindl bernhardkaindl changed the title CP-49931: Moved xe-reset-networking from scripts/xe-reset-networking to python3/bin CP-49931: mv scripts/xe-reset-networking to python3/bin Jul 11, 2024
@bernhardkaindl bernhardkaindl changed the title CP-49931: mv scripts/xe-reset-networking to python3/bin CP-49931: mv scripts/xe-reset-networking to python3/bin Jul 11, 2024
@bernhardkaindl bernhardkaindl requested a review from liulinC July 12, 2024 12:44
@psafont
Copy link
Member

psafont commented Jul 15, 2024

There are some conflicts, this needs rebasing

@ashwin9390
Copy link
Contributor Author

There are some conflicts, this needs rebasing

Working on it

Fix pyright:
    - Rework unclean exception handling using a contextmanager.
    - Declare address and master in case of an Exception as well.
    - Fix warning on unsupported escape sequence using a raw string.
    - Removed python2 script check from pyproject.toml

Signed-off-by: Bernhard Kaindl <[email protected]>

Signed-off-by: Ashwinh <[email protected]>
@bernhardkaindl bernhardkaindl merged commit 6b056d5 into xapi-project:feature/py3 Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants