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 formatting #680

Merged
merged 2 commits into from
Jul 3, 2024
Merged

Ruff formatting #680

merged 2 commits into from
Jul 3, 2024

Conversation

niccokunzmann
Copy link
Member

This contributes to #672

  • add github action to test code

@niccokunzmann
Copy link
Member Author

This is the output:

creating virtual environment...
installing ruff...
bootstrap.py:93:1: E402 Module level import not at top of file
   |
91 | setup_args = {'to_dir': tmpeggs, 'download_delay': 0}
92 | ez['use_setuptools'](**setup_args)
93 | import setuptools
   | ^^^^^^^^^^^^^^^^^ E402
94 | import pkg_resources
   |

bootstrap.py:94:1: E402 Module level import not at top of file
   |
92 | ez['use_setuptools'](**setup_args)
93 | import setuptools
94 | import pkg_resources
   | ^^^^^^^^^^^^^^^^^^^^ E402
95 | 
96 | # This does not (always?) update the default working set.  We will
   |

bootstrap.py:158:1: E402 Module level import not at top of file
    |
156 | cmd.append(requirement)
157 | 
158 | import subprocess
    | ^^^^^^^^^^^^^^^^^ E402
159 | if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
160 |     raise Exception(
    |

126 |     for o in rdate: rs.rdate(o)
127 |     for o in exrule: rs.exrule(o)
    |

src/icalendar/timezone/zoneinfo.py:126:19: E701 Multiple statements on one line (colon)
    |
124 |     rs = rruleset(cache)
125 |     for o in rrule: rs.rrule(o)
126 |     for o in rdate: rs.rdate(o)
    |                   ^ E701
127 |     for o in exrule: rs.exrule(o)
128 |     for o in exdate: rs.exdate(o)
    |

src/icalendar/timezone/zoneinfo.py:127:20: E701 Multiple statements on one line (colon)
    |
125 |     for o in rrule: rs.rrule(o)
126 |     for o in rdate: rs.rdate(o)
127 |     for o in exrule: rs.exrule(o)
    |                    ^ E701
128 |     for o in exdate: rs.exdate(o)
129 |     return rs
    |

src/icalendar/timezone/zoneinfo.py:128:20: E701 Multiple statements on one line (colon)
    |
126 |     for o in rdate: rs.rdate(o)
127 |     for o in exrule: rs.exrule(o)
128 |     for o in exdate: rs.exdate(o)
    |                    ^ E701
129 |     return rs
    |

Found 71 errors.
[*] 4 fixable with the `--fix` option (4 hidden fixes can be enabled with the `--unsafe-fixes` option).
Error: Process completed with exit code 1.

@niccokunzmann
Copy link
Member Author

Also, one can run ruff format to format files in case ruff can actually do the work for us.

@coveralls
Copy link

coveralls commented Jul 2, 2024

Pull Request Test Coverage Report for Build 9767250837

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 97.559%

Totals Coverage Status
Change from base Build 9767068472: 0.0%
Covered Lines: 3078
Relevant Lines: 3155

💛 - Coveralls

@niccokunzmann
Copy link
Member Author

We can describe how to test files, too:

#pyproject.toml
[tool.ruff]
target-version = "py38"

[tool.ruff.lint]
select = ["ALL"]
ignore = [
    "ANN",     # flake8-annotations
    "B020",    # Loop control variable {name} overrides iterable it iterates
    "C401",    # Unnecessary generator (rewrite as a set comprehension)
    "C901",    # {name} is too complex ({complexity} > {max_complexity})
    "COM812",  # Trailing comma missing
    "D1",      # Missing docstring
    "D2",      # docstrings stuffs
    "D4",      # docstrings stuffs
    "EM10",    # Exception string usage
    "ERA001",  # Found commented-out code
    "FBT002",  # Boolean default positional argument in function definition
    "FIX",     # TODO comments
    "ISC001",  # Implicitly concatenated string literals on one line (to avoid with formatter)
    "N818",    # Exception name {name} should be named with an Error suffix
    "PLR091",  # Too many things (complexity, arguments, branches, etc...)
    "PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
    "RUF012",  # Mutable class attributes should be annotated with typing.ClassVar
    "RUF015",  # Prefer next({iterable}) over single element slice
    "S101",    # Use of assert detected
    "TD",      # TODO comments
    "TRY003",  # Avoid specifying long messages outside the exception class
    "S104",    # Possible binding to all interfaces
    "E722",    # Do not use bare `except`
    "RUF005",  # Consider iterable unpacking instead of concatenation
    "DTZ005",  # `datetime.datetime.now()` called without a `tz` argument
    "PERF401", # Use a list comprehension to create a transformed list
    "ARG002",  # Unused method argument: ...
    "ARG001",  # Unused function argument: ...
]
extend-safe-fixes = [
    "PT006", # Wrong type passed to first argument of @pytest.mark.parametrize; expected {expected_string}
]

[tool.ruff.lint.per-file-ignores]
"test/*" = [
    "B011",   # Do not assert False (python -O removes these calls), raise AssertionError()
    "DTZ001", # datetime.datetime() called without a tzinfo argument
    "E501",   # Indentation is not a multiple of {indent_size}
    "N802",   # Function name {name} should be lowercase
    "PT011",  # pytest.raises({exception}) is too broad, set the match parameter or use a more specific exception
    "PT012",  # pytest.raises() block should contain a single simple statement
    "PT015",  # Assertion always fails, replace with pytest.fail()
    "T201",   # print found
    "T203",   # `pprint` found
    "RUF001", # String contains ambiguous character
]
"features/*" = [
    "F811",   # Redefinition of unused `step_impl` from line 52
    "T201",   # `print` found
]

"static/js/dhtmlx/locale/convert.py" = [
  "INP001",    # File `static/js/dhtmlx/locale/convert.py` is part of an implicit namespace package. Add an `__init__.py`
  "T201",      # print found
  "PTH123",
  "S307",
  "PTH103",
  "PLW2901"
]

"docs/hooks/set_canonical_url.py" = [
  "INP001"    # File `docs/hooks/set_canonical_url.py` is part of an implicit namespace package. Add an `__init__.py`.
]

.github/workflows/ruff.yml Show resolved Hide resolved
@niccokunzmann niccokunzmann mentioned this pull request Jul 3, 2024
6 tasks
@coveralls
Copy link

coveralls commented Jul 3, 2024

Pull Request Test Coverage Report for Build 9779036408

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 97.559%

Totals Coverage Status
Change from base Build 9767068472: 0.0%
Covered Lines: 3078
Relevant Lines: 3155

💛 - Coveralls

@niccokunzmann
Copy link
Member Author

changelog added ... merging. Thanks for the review!

@niccokunzmann niccokunzmann merged commit a1e30fb into main Jul 3, 2024
17 checks passed
@niccokunzmann niccokunzmann deleted the ruff branch July 3, 2024 13:49
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.

None yet

3 participants