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

GitHub Actions: Lint with ruff instead of flake8 #47

Closed
wants to merge 1 commit into from

Conversation

cclauss
Copy link

@cclauss cclauss commented Nov 27, 2023

% ruff .

examples/client.py:159:51: E703 [*] Statement ends with an unnecessary semicolon
setup.py:24:8: F401 [*] `os` imported but unused
setup.py:25:8: F401 [*] `sys` imported but unused
setup.py:27:42: F401 [*] `setuptools.command.build_ext.build_ext` imported but unused
wolfssl/__init__.py:31:35: F401 [*] `socket.SOL_SOCKET` imported but unused
wolfssl/__init__.py:31:47: F401 [*] `socket.SO_TYPE` imported but unused
wolfssl/__init__.py:490:33: E703 [*] Statement ends with an unnecessary semicolon
wolfssl/__init__.py:1001:29: F841 [*] Local variable `e` is assigned to but never used
wolfssl/_build_ffi.py:25:8: F401 [*] `argparse` imported but unused
wolfssl/_build_ffi.py:108:9: E722 Do not use bare `except`
Found 10 errors.
[*] 9 fixable with the `--fix` option.

% ruff --fix .

wolfssl/_build_ffi.py:107:9: E722 Do not use bare `except`
Found 10 errors (9 fixed, 1 remaining).

% code wolfssl/_build_ffi.py
% ruff rule E722

bare-except (E722)

Derived from the pycodestyle linter.

What it does

Checks for bare except catches in try-except statements.

Why is this bad?

A bare except catches BaseException which includes
KeyboardInterrupt, SystemExit, Exception, and others. Catching
BaseException can make it hard to interrupt the program (e.g., with
Ctrl-C) and can disguise other problems.

Example

try:
    raise KeyboardInterrupt("You probably don't mean to break CTRL-C.")
except:
    print("But a bare `except` will ignore keyboard interrupts.")

Use instead:

try:
    do_something_that_might_break()
except MoreSpecificException as e:
    handle_error(e)

If you actually need to catch an unknown error, use Exception which will
catch regular program errors but not important system exceptions.

def run_a_function(some_other_fn):
    try:
        some_other_fn()
    except Exception as e:
        print(f"How exceptional! {e}")

References

@wolfSSL-Bot
Copy link

Can one of the admins verify this patch?

@anhu
Copy link
Member

anhu commented Nov 27, 2023

Hello again @cclauss ,

This one seems much more substantial. I shall get our reviewer to have a look for you. Please stay tuned.

Warm regards, Anthony

Copy link
Contributor

@JacobBarthelmeh JacobBarthelmeh left a comment

Choose a reason for hiding this comment

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

Thanks @cclauss ! Lets look at getting a contributor agreement in place so we can merge in code changes. Please contact us at [email protected]

@cclauss cclauss closed this Mar 26, 2024
@cclauss cclauss deleted the ruff branch March 26, 2024 15:40
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.

4 participants