8000 `--autofix` doesn't seem to work for `tryceratops>=2.2.0` · Issue #66 · guilatrova/tryceratops · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

--autofix doesn't seem to work for tryceratops>=2.2.0 #66

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

Open
kdestin opened this issue Jun 1, 2023 · 0 comments
Open

--autofix doesn't seem to work for tryceratops>=2.2.0 #66

kdestin opened this issue Jun 1, 2023 · 0 comments

Comments

@kdestin
Copy link
kdestin commented Jun 1, 2023

Environment

Operating System: Ubuntu 22.04 (kernel 5.15.0-72-generic)
Tryceratops Version: 2.3.2 (But I've also observed this issue with 2.2.0)
pip list:

Package           Version
----------------- -------
click             8.1.3
markdown-it-py    2.2.0
mdurl             0.1.2
pip               20.3.3
Pygments          2.15.1
rich              13.4.1
setuptools        67.6.0
toml              0.10.2
tryceratops       2.3.2
typing-extensions 4.6.2
wheel             0.37.0

Describe the problem

I was trying to use tryceratops to fix some issues in my codebase. I was specifically interested in fixing TRY200 and noticed that using --autofix didn't seem to actually do anything.

I was able to reproduce this problem with 2.3.2 and 2.2.0
I was able to confirm that--autofix was working with versions: 2.0.0, 2.1.0 and 2.1.1

Steps to Reproduce

  1. Install tryceratops==2.3.2

  2. Prepare file that intentionally violates TRY200, TRY201, and TRY400. (Taken from the documentation for each of those checks).

    # Try200
    def main_function():
        try:
            process()
            handle()
            finish()
        except Exception:
            raise MainFunctionFailed()
    
    # Try201
    try:
        ...
    except CustomException as ex:
        raise ex
    
    # Try400
    def main_function():
        try:
            process()
            handle()
            finish()
        except Exception as ex:
            logger.error("Context message here")
  3. Run tryceratops --autofix repro.py

Expected Behavior

$ tryceratops --autofix repro.py
[TRY400] Use logging '.exception' instead of '.error' - repro.py:23:8
[TRY200] Use 'raise from' to specify exception cause - repro.py:8:8
[TRY203] Useless try-except, remove it or handle the exception - repro.py:11:0
[TRY201] Simply use 'raise' without specifying exception object again - repro.py:14:4
Done processing!
Processed 1 files
Found 4 violations
Fixed 3 violations

Actual Behavior

$ tryceratops --autofix repro.py
[TRY203] Useless try-except, remove it or handle the exception - repro.py:11:0
[TRY400] Use logging '.exception' instead of '.error' - repro.py:23:8
[TRY201] Simply use 'raise' without specifying exception object again - repro.py:14:4
[TRY200] Use 'raise from' to specify exception cause - repro.py:8:8
Done processing!
Processed 1 files
Found 4 violations

Note the missing Fixed 3 violations

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
0