Skip to content

Commit

Permalink
Add python linter to GitHub workflow
Browse files Browse the repository at this point in the history
Add the ruff python linter to the GitHub workflow and fix the errors it
found.

Signed-off-by: Chmouel Boudjnah <[email protected]>
  • Loading branch information
chmouel authored and tekton-robot committed Jan 12, 2024
1 parent b7c574e commit 9aeb788
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Ruff - Python Linter
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
4 changes: 1 addition & 3 deletions sync/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import os.path
import re
import sys
from urllib.error import URLError
from urllib.parse import urlparse, urljoin, urlunparse

from bs4 import BeautifulSoup
Expand Down Expand Up @@ -291,7 +290,6 @@ def transform_link(link, base_path, local_files, rewrite_path, rewrite_url):
if is_fragment(parsed):
# A fragment only link points to an .md file
return urlunparse(parsed._replace(fragment=parsed.fragment.lower()))
path = os.path.normpath(parsed.path)

# The list if local_file includes paths based on the root of the git
# repo, so we need join base_path and normalize to fq_path to find the
Expand Down Expand Up @@ -381,7 +379,7 @@ def get_files_in_path(path, file_type):
file_list = []

# walk through every file in directory and its sub directories
for root, dirs, files in os.walk(path):
for root, _, files in os.walk(path):
for file in files:
# append the file name to the list if is it the correct type
if file.endswith(file_type):
Expand Down
4 changes: 2 additions & 2 deletions sync/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ def test_transform_links_doc(self):
"/docs/test/test.txt)")
]

for case, expected in zip(cases, expected_results):
actual = transform_links_doc(
for case, _ in zip(cases, expected_results):
transform_links_doc(
text=case, base_path=base_path, local_files=local_files,
rewrite_path='/docs/test', rewrite_url='http://test.com/tree/docs/test'
)
Expand Down
2 changes: 1 addition & 1 deletion sync/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def command(cmd_fn, config_folder, project, version):
configs = load_config(config_folder)
config = select_config(configs, project)
if not config:
raise Exception(f'Cound not find a config for {project} in {config_files}')
raise Exception(f'Cound not find a config for {project} in {configs}')
try:
cmd_fn(config, version)
sync.save_config(configs)
Expand Down

0 comments on commit 9aeb788

Please sign in to comment.