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

Unrecoverable exception thrown when parsing when parsing a module #2288

Open
daskol opened this issue Sep 5, 2024 · 0 comments
Open

Unrecoverable exception thrown when parsing when parsing a module #2288

daskol opened this issue Sep 5, 2024 · 0 comments

Comments

@daskol
Copy link

daskol commented Sep 5, 2024

Here is a source file which causes the issue.

# datasets/__init__.py
from .dataset import batched3, load_dataset, sample_negatives

__all__ = ('batched3', 'load_dataset', 'sample_negatives')

Here is a pre-commit configuration file (if one omits args then everything is fine).

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/pycqa/isort
    rev: 5.13.2
    hooks:
      - id: isort
        args: ['-c']

Here is a stack trace produced by pre-commit hook.

ERROR: Unrecoverable exception thrown when parsing dataset/__init__.py! This should NEVER happen.
If encountered, please open an issue: https://github.com/PyCQA/isort/issues/new
Traceback (most recent call last):
  File "/home/username/.cache/pre-commit/repo5m26nnl8/py_env-python3.12/bin/isort", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/username/.cache/pre-commit/repo5m26nnl8/py_env-python3.12/lib/python3.12/site-packages/isort/main.py", line 1228, in main
    for sort_attempt in attempt_iterator:
                        ^^^^^^^^^^^^^^^^
  File "/home/username/.cache/pre-commit/repo5m26nnl8/py_env-python3.12/lib/python3.12/site-packages/isort/main.py", line 1212, in <genexpr>
    sort_imports(  # type: ignore
  File "/home/username/.cache/pre-commit/repo5m26nnl8/py_env-python3.12/lib/python3.12/site-packages/isort/main.py", line 87, in sort_imports
    incorrectly_sorted = not api.check_file(file_name, config=config, **kwargs)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/.cache/pre-commit/repo5m26nnl8/py_env-python3.12/lib/python3.12/site-packages/isort/api.py", line 338, in check_file
    return check_stream(
           ^^^^^^^^^^^^^
  File "/home/username/.cache/pre-commit/repo5m26nnl8/py_env-python3.12/lib/python3.12/site-packages/isort/api.py", line 264, in check_stream
    changed: bool = sort_stream(
                    ^^^^^^^^^^^^
  File "/home/username/.cache/pre-commit/repo5m26nnl8/py_env-python3.12/lib/python3.12/site-packages/isort/api.py", line 210, in sort_stream
    changed = core.process(
              ^^^^^^^^^^^^^
  File "/home/username/.cache/pre-commit/repo5m26nnl8/py_env-python3.12/lib/python3.12/site-packages/isort/core.py", line 153, in process
    sort_section_pointer += output_stream.write(sorted_code)
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'
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

No branches or pull requests

1 participant