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

Ruff rules: Stricter code quality rules #438

Merged
merged 11 commits into from
Aug 20, 2023
Merged

Ruff rules: Stricter code quality rules #438

merged 11 commits into from
Aug 20, 2023

Commits on Aug 20, 2023

  1. Configuration menu
    Copy the full SHA
    1e2925b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    80555a5 View commit details
    Browse the repository at this point in the history
  3. refactor(pytest_plugin): Consolidate exceptions

    src/libvcs/pytest_plugin.py:176:19: TRY002 Create your own exception
    src/libvcs/pytest_plugin.py:176:19: TRY003 Avoid specifying long messages outside the exception class
    tony committed Aug 20, 2023
    Configuration menu
    Copy the full SHA
    eda6c42 View commit details
    Browse the repository at this point in the history
  4. chore(pytest-plugin): Manual fix for arg defaults

    src/libvcs/pytest_plugin.py:210:34: B006 [*] Do not use mutable data structures for argument defaults
    src/libvcs/pytest_plugin.py:234:38: B006 [*] Do not use mutable data structures for argument defaults
    tony committed Aug 20, 2023
    Configuration menu
    Copy the full SHA
    e212def View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    fe8f2a4 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0dbeb70 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    10ab0cc View commit details
    Browse the repository at this point in the history
  8. refactor(query_list): Ruff fixes

    src/libvcs/_internal/query_list.py:87:9: TRY300 Consider moving this statement to an `else` block
    src/libvcs/_internal/query_list.py:119:9: SIM102 Use a single `if` statement instead of nested `if` statements
    src/libvcs/_internal/query_list.py:451:19: TRY002 Create your own exception
    src/libvcs/_internal/query_list.py:451:19: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/_internal/query_list.py:489:25: TRY301 Abstract `raise` to an inner function
    src/libvcs/_internal/query_list.py:489:31: TRY003 Avoid specifying long messages outside the exception class
    tony committed Aug 20, 2023
    Configuration menu
    Copy the full SHA
    83c6cff View commit details
    Browse the repository at this point in the history
  9. chore(ruff): Automated fixes (Fix 103 warnings)

    Fixed 105 errors:
    - conftest.py:
         1 × UP006 (non-pep585-annotation)
    - docs/conf.py:
         1 × RUF100 (unused-noqa)
         1 × SIM108 (if-else-block-instead-of-if-exp)
         1 × I001 (unsorted-imports)
    - src/libvcs/_internal/query_list.py:
         6 × ERA001 (commented-out-code)
         1 × SIM118 (in-dict-keys)
    - src/libvcs/_internal/run.py:
         3 × ERA001 (commented-out-code)
    - src/libvcs/_internal/types.py:
         1 × RUF100 (unused-noqa)
    - src/libvcs/cmd/git.py:
         8 × RUF005 (collection-literal-concatenation)
         1 × SIM108 (if-else-block-instead-of-if-exp)
         1 × SIM102 (collapsible-if)
    - src/libvcs/cmd/hg.py:
         1 × SIM108 (if-else-block-instead-of-if-exp)
    - src/libvcs/cmd/svn.py:
         2 × UP006 (non-pep585-annotation)
         1 × SIM108 (if-else-block-instead-of-if-exp)
         1 × F401 (unused-import)
    - src/libvcs/sync/base.py:
         1 × UP031 (printf-string-formatting)
         1 × UP032 (f-string)
    - src/libvcs/sync/git.py:
         1 × UP031 (printf-string-formatting)
         1 × SIM102 (collapsible-if)
         1 × ERA001 (commented-out-code)
         1 × SIM108 (if-else-block-instead-of-if-exp)
    - src/libvcs/sync/hg.py:
         1 × RUF100 (unused-noqa)
    - src/libvcs/sync/svn.py:
         1 × RUF100 (unused-noqa)
         1 × ERA001 (commented-out-code)
         1 × SIM108 (if-else-block-instead-of-if-exp)
         1 × B007 (unused-loop-control-variable)
    - src/libvcs/url/git.py:
         1 × RUF100 (unused-noqa)
         1 × C416 (unnecessary-comprehension)
         1 × B010 (set-attr-with-constant)
    - src/libvcs/url/hg.py:
         1 × RUF100 (unused-noqa)
         1 × B010 (set-attr-with-constant)
    - src/libvcs/url/registry.py:
         6 × UP006 (non-pep585-annotation)
    - src/libvcs/url/svn.py:
         2 × RUF100 (unused-noqa)
         1 × ERA001 (commented-out-code)
         1 × B010 (set-attr-with-constant)
    - tests/_internal/test_query_list.py:
        28 × C408 (unnecessary-collection-call)
         2 × SIM300 (yoda-conditions)
    - tests/sync/test_base.py:
         2 × SIM300 (yoda-conditions)
         1 × RUF010 (explicit-f-string-type-conversion)
    - tests/sync/test_git.py:
         3 × SIM300 (yoda-conditions)
         1 × C416 (unnecessary-comprehension)
         1 × I001 (unsorted-imports)
    - tests/test_pytest_plugin.py:
         1 × ERA001 (commented-out-code)
         1 × RUF015 (unnecessary-iterable-allocation-for-first-element)
    - tests/url/test_git.py:
         1 × ERA001 (commented-out-code)
    - tests/url/test_hg.py:
         1 × ERA001 (commented-out-code)
    - tests/url/test_registry.py:
         3 × UP006 (non-pep585-annotation)
         1 × B007 (unused-loop-control-variable)
    - tests/url/test_svn.py:
         1 × ERA001 (commented-out-code)
    tony committed Aug 20, 2023
    Configuration menu
    Copy the full SHA
    06f4b43 View commit details
    Browse the repository at this point in the history
  10. refactor: Manual fixes for ruff warnings (43 warnings fixed)

    docs/conf.py:208:9: PERF203 `try`-`except` within a loop incurs performance overhead
    src/libvcs/_internal/shortcuts.py:108:19: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/_internal/shortcuts.py:108:19: F821 Undefined name `LibVCSException`
    src/libvcs/_internal/shortcuts.py:110:19: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/_internal/shortcuts.py:110:19: F821 Undefined name `LibVCSException`
    src/libvcs/_internal/shortcuts.py:120:19: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/_internal/subprocess.py:437:15: TRY002 Create your own exception
    src/libvcs/_internal/subprocess.py:437:15: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/cmd/svn.py:822:19: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/sync/git.py:143:19: TRY002 Create your own exception
    src/libvcs/sync/git.py:143:19: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/sync/git.py:275:19: TRY002 Create your own exception
    src/libvcs/sync/git.py:275:19: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/sync/git.py:385:13: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:410:23: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/sync/git.py:439:13: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:447:17: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:459:21: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:465:17: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:473:21: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:480:21: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:498:25: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:498:25: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:509:17: TRY400 Use `logging.exception` instead of `logging.error`
    src/libvcs/sync/git.py:589:19: TRY002 Create your own exception
    src/libvcs/sync/git.py:589:19: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/sync/git.py:676:23: TRY002 Create your own exception
    src/libvcs/sync/git.py:676:23: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/sync/svn.py:107:12: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
    src/libvcs/sync/svn.py:107:45: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()`
    src/libvcs/sync/svn.py:118:26: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
    src/libvcs/sync/svn.py:119:20: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
    src/libvcs/sync/svn.py:159:24: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
    src/libvcs/sync/svn.py:160:12: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
    src/libvcs/sync/svn.py:161:18: PTH123 `open()` should be replaced by `Path.open()`
    src/libvcs/sync/svn.py:175:23: TRY003 Avoid specifying long messages outside the exception class
    src/libvcs/url/git.py:291:20: B007 Loop control variable `v` not used within loop body
    src/libvcs/url/hg.py:220:20: B007 Loop control variable `v` not used within loop body
    src/libvcs/url/svn.py:204:20: B007 Loop control variable `v` not used within loop body
    tests/sync/test_git.py:110:12: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
    tests/sync/test_hg.py:55:10: B017 `pytest.raises(Exception)` should be considered evil
    tests/sync/test_svn.py:29:12: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
    tests/test_exc.py:12:15: TRY003 Avoid specifying long messages outside the exception class
    tests/test_exc.py:38:15: TRY003 Avoid specifying long messages outside the exception class
    tony committed Aug 20, 2023
    Configuration menu
    Copy the full SHA
    1018173 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    e16a5d4 View commit details
    Browse the repository at this point in the history