Skip to content

fix: improve --ignore-errors handling for notebook and syntax errors#518

Open
KushalLukhi wants to merge 1 commit intobndr:masterfrom
KushalLukhi:fix/ignore-errors-notebooks
Open

fix: improve --ignore-errors handling for notebook and syntax errors#518
KushalLukhi wants to merge 1 commit intobndr:masterfrom
KushalLukhi:fix/ignore-errors-notebooks

Conversation

@KushalLukhi
Copy link

This PR addresses two related issues:

Fixes #485 - --ignore-errors flag not working with notebooks:

  • ipynb_2_py() now catches exceptions and logs warnings instead of crashing
  • read_file_content() raises ValueError when notebook parsing fails
  • Errors now properly propagate to the ignore_errors handler in get_all_imports()

Fixes #494 - SyntaxError with Python 2 syntax:

  • Added better SyntaxError handling in get_all_imports()
  • Provides helpful warning message about Python 2 syntax detection
  • Suggests using --ignore-errors flag when SyntaxError occurs

Changes:

  • Modified ipynb_2_py() to catch exceptions and return None
  • Modified read_file_content() to raise ValueError on notebook failures
  • Enhanced error handling in get_all_imports() for syntax errors
  • Added tests for ignore_errors with invalid notebooks and Python 2 syntax

Testing:

  • Added test_ignore_errors_with_invalid_notebook()
  • Added test_ignore_errors_with_syntax_error()

Closes #485, #494

This PR addresses two related issues:

Fixes bndr#485 - --ignore-errors flag not working with notebooks:

- ipynb_2_py now catches exceptions and logs warnings

- read_file_content raises ValueError when notebook parsing fails

- Errors now properly propagate to the ignore_errors handler

Fixes bndr#494 - SyntaxError with Python 2 syntax:

- Added better SyntaxError handling in get_all_imports

- Provides helpful warning message about Python 2 syntax

- Suggests using --ignore-errors flag when SyntaxError occurs

Changes:

- Modified ipynb_2_py to catch exceptions and return None

- Modified read_file_content to raise ValueError on notebook failures

- Enhanced error handling in get_all_imports for syntax errors

- Added tests for ignore_errors with invalid notebooks and Python 2 syntax

Testing:

- Added test_ignore_errors_with_invalid_notebook

- Added test_ignore_errors_with_syntax_error
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.

SyntaxError during pipreqs execution due to legacy Python syntax in source file --ignore-errors flag not working...

1 participant