Skip to content

Commit

Permalink
Formatting/linting fixes
Browse files Browse the repository at this point in the history
Fix `invoke lint` to check all files, not only robotstatuschecker.py
and fix revealed issues.
  • Loading branch information
pekkaklarck committed Feb 3, 2025
1 parent bb9eb14 commit 9e58e6a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ lint.ignore = [
"T201", # Allow print
"N818", # Don't require exceptions names to end with Error
"PTH100", # Allow using os.path (we want normpath() instead of Path.resolve())
"PTH123", # Allow using open() instead of Path.open()
"B904", # Don't require from clause with raise inside except
"SIM102", # Don't force combining nested ifs
]
Expand Down Expand Up @@ -40,12 +41,6 @@ lint.select = [
"SIM",
"RUF"
]
[tool.ruff.lint.per-file-ignores]
"tasks.py" = [
"T201",
"PTH123",
"PTH120"
]

[[tool.mypy.overrides]]
module = ["robot.api.*"]
Expand Down
47 changes: 25 additions & 22 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys
from pathlib import Path
Expand All @@ -28,14 +29,13 @@
RELEASE_NOTES_INTRO = """
StatusChecker is a tool for validating that executed `Robot Framework`_ test cases
have expected statuses and log messages. It is mainly useful for Robot Framework
test library developers who want to use Robot Framework to also test their libraries.
StatusChecker 1.4 and newer are compatible both with Python 2 and Python 3.
library developers who want to use Robot Framework to also test their libraries.
StatusChecker project is hosted at GitHub and downloads are at PyPI_
.. _Robot Framework: http://robotframework.org
.. _PyPI: https://github.com/robotframework/statuschecker
.. _issue tracker: https://github.com/robotframework/SeleniumLibrary/issues?q=milestone%3A{version.milestone}
""" # noqa
"""

IS_GITHUB_ACTIONS = os.environ.get("GITHUB_ACTIONS_RUNNIN_RUFF_LINT")

Expand Down Expand Up @@ -108,31 +108,34 @@ def init_labels(ctx, username=None, password=None):

@task
def lint(ctx):
"""Run linters
"""Run linters, type checkers and formatters.
Ruff, mypy and robotframework-tidy
Ruff, mypy and Robotidy.
"""
ruff_format = "ruff format"
ruff_check = "ruff check"
mypy = r"mypy --exclude \.venv robotstatuschecker.py"
tidy = " ".join(
[
"robotidy",
"--lineseparator",
"unix",
"--configure",
"NormalizeAssignments:equal_sign_type=space_and_equal_sign",
"--configure",
"NormalizeAssignments:equal_sign_type_variables=space_and_equal_sign",
"test",
]
)
if IS_GITHUB_ACTIONS:
ruff_format = f"{ruff_format} --check"
else:
ruff_check = f"{ruff_check} --fix"
ruff_check = f"{ruff_check} robotstatuschecker.py"
print(f"Running ruff format· {ruff_format}")
print(f"Formatting ({ruff_format}):")
ctx.run(ruff_format)
print(f"Running ruff check: {ruff_check}")
ctx.run("ruff check robotstatuschecker.py")
print("Running mypy")
ctx.run("mypy --exclude \\.venv robotstatuschecker.py")
tidy_command = [
"robotidy",
"--lineseparator",
"unix",
"--configure",
"NormalizeAssignments:equal_sign_type=space_and_equal_sign",
"--configure",
"NormalizeAssignments:equal_sign_type_variables=space_and_equal_sign",
"test",
]
ctx.run(" ".join(tidy_command))
print(f"\nLinting ({ruff_check}):")
ctx.run(ruff_check)
print(f"\nType checking ({mypy}):")
ctx.run(mypy)
print(f"\nTidy ({tidy}):")
ctx.run(tidy)
5 changes: 3 additions & 2 deletions test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path
from platform import python_implementation, python_version

from robot import run, rebot
from robot import rebot, run
from robot.api import ExecutionResult, ResultVisitor

CURDIR = Path(__file__).resolve().parent
Expand Down Expand Up @@ -86,7 +86,8 @@ def print_status(self):
print(f"All {self.tests} tests passed/failed/logged/skipped as expected.")
print("-" * 78)
print(
f"Robot Framework {VERSION} on {python_implementation()} {python_version()}."
f"Robot Framework {VERSION} on {python_implementation()} "
f"{python_version()}."
)


Expand Down

0 comments on commit 9e58e6a

Please sign in to comment.