Skip to content

fix: use except Exception and is not None in data_selection/utils.py#365

Open
harshadkhetpal wants to merge 1 commit intomicrosoft:mainfrom
harshadkhetpal:fix/pep8-utils
Open

fix: use except Exception and is not None in data_selection/utils.py#365
harshadkhetpal wants to merge 1 commit intomicrosoft:mainfrom
harshadkhetpal:fix/pep8-utils

Conversation

@harshadkhetpal
Copy link

Summary

Two PEP8 / correctness fixes in data_selection/utils.py:

  1. Bare except:except Exception: — The import guard for transformers.mpu used a bare except: which silently catches KeyboardInterrupt and SystemExit. Since there is no re-raise, except Exception: is the correct choice — it catches all regular import errors while letting system signals propagate.

  2. != Noneis not None — PEP8 E711: comparisons to None should always use is / is not, not == / !=.

Changes:

# Before
except:
    mpu = None

# After
except Exception:
    mpu = None
# Before
if args.save != None:

# After
if args.save is not None:

Testing

No behavior change — style/correctness fixes only.

Two PEP8/correctness fixes:
1. Replace bare `except:` with `except Exception:` on import guard
2. Replace `!= None` comparison with `is not None` (PEP8 E711)
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.

1 participant