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

Fix Ruff on error #701

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Fix Ruff on error #701

merged 1 commit into from
Nov 14, 2024

Conversation

sbrunner
Copy link
Member

@sbrunner sbrunner commented Nov 14, 2024

Description

Currently, we get:

Traceback (most recent call last):
  File "/home/runner/.cache/pre-commit/repoi1wsp71_/py_env-python3/lib/python3.13/site-packages/prospector/run.py", line 87, in execute
    messages += tool.run(found_files)
                ~~~~~~~~^^^^^^^^^^^^^
  File "/home/runner/.cache/pre-commit/repoi1wsp71_/py_env-python3/lib/python3.13/site-packages/prospector/tools/ruff/__init__.py", line 51, in run
    for message in json.loads(completed_process.stdout):
                   ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.0/x64/lib/python3.13/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/opt/hostedtoolcache/Python/3.13.0/x64/lib/python3.13/json/decoder.py", line 344, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.0/x64/lib/python3.13/json/decoder.py", line 362, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/.cache/pre-commit/repoi1wsp71_/py_env-python3/bin/prospector", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/runner/.cache/pre-commit/repoi1wsp71_/py_env-python3/lib/python3.13/site-packages/prospector/run.py", line 200, in main
    prospector.execute()
    ~~~~~~~~~~~~~~~~~~^^
  File "/home/runner/.cache/pre-commit/repoi1wsp71_/py_env-python3/lib/python3.13/site-packages/prospector/run.py", line 105, in execute
    raise FatalProspectorException(f"Tool {toolname} failed to run.") from ex
prospector.exceptions.FatalProspectorException: Tool ruff failed to run.

The new output with pylint output will be:

(ruff): error: unexpected argument '--unsafe-fix' found

  tip: a similar argument exists: '--unsafe-fixes'

Usage: ruff check <FILES|--fix|--no-fix|--unsafe-fixes|--no-unsafe-fixes|--show-fixes|--no-show-fixes|--diff|--watch|--fix-only|--no-fix-only|--ignore-noqa|--output-format <OUTPUT_FORMAT>|--output-file <OUTPUT_FILE>|--target-version <TARGET_VERSION>|--preview|--no-preview|--select <RULE_CODE>|--ignore <RULE_CODE>|--extend-select <RULE_CODE>|--extend-ignore <RULE_CODE>|--per-file-ignores <PER_FILE_IGNORES>|--extend-per-file-ignores <EXTEND_PER_FILE_IGNORES>|--exclude <FILE_PATTERN>|--extend-exclude <FILE_PATTERN>|--fixable <RULE_CODE>|--unfixable <RULE_CODE>|--extend-fixable <RULE_CODE>|--extend-unfixable <RULE_CODE>|--respect-gitignore|--no-respect-gitignore|--force-exclude|--no-force-exclude|--line-length <LINE_LENGTH>|--dummy-variable-rgx <DUMMY_VARIABLE_RGX>|--no-cache|--cache-dir <CACHE_DIR>|--stdin-filename <STDIN_FILENAME>|--extension <EXTENSION>|--exit-zero|--exit-non-zero-on-fix|--statistics|--add-noqa|--show-files|--show-settings>

For more information, try '--help'.

Check Information
=================
         Started: 2024-11-14 09:55:33.038829
        Finished: 2024-11-14 09:55:33.161889
      Time Taken: 0.12 seconds
       Formatter: pylint
        Profiles: .prospector.yaml, utils:base, strictness_veryhigh, utils:no-design-checks, utils:fix, utils:unsafe, utils:c2cwsgiutils, duplicated, duplicated:black, duplicated:isort, duplicated:pyupgrade, duplicated:pylint, duplicated:docformatter, duplicated:autoflake, duplicated:pydocstyle, no_doc_warnings, no_member_warnings, no_test_warnings
      Strictness: from profile
  Libraries Used: 
       Tools Run: ruff
  Messages Found: 1

How Has This Been Tested?

Tested on error with all outputs!

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@sbrunner sbrunner changed the title Fix ruff json Fix Ruff on error Nov 14, 2024
@sbrunner sbrunner added this to the 1.13.2 milestone Nov 14, 2024
Copy link
Collaborator

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -85,11 +85,10 @@ def blend(messages: list[Message], blend_combos: Optional[list[list[tuple[str, s
blend_combos = blend_combos or BLEND_COMBOS

# group messages by file and then line number
msgs_grouped: dict[Path, dict[int, list[Message]]] = defaultdict(lambda: defaultdict(list))
msgs_grouped: dict[Optional[Path], dict[Optional[int], list[Message]]] = defaultdict(lambda: defaultdict(list))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:Path |None will work if we import annotations from __future__, right ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know, personally, I prefer waiting for Python 3.10 witch supports that natively

@sbrunner sbrunner merged commit f885e03 into master Nov 14, 2024
5 checks passed
@sbrunner sbrunner deleted the fix-ruff-json branch November 14, 2024 10:25
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.

2 participants