Skip to content

Commit

Permalink
ci: fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ObstinateM committed Sep 20, 2024
1 parent d4e5175 commit 2840af5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/scripts/validate_commit_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

def load_commit_types():
"""
Load valid commit types from the commit_type.json file located in the same directory as the script.
Load valid commit types from the commit_type.json file located in the same directory as
the script.
Returns:
list: A list of valid commit types in lowercase.
Expand All @@ -23,8 +24,8 @@ def load_commit_types():
json_file_path = os.path.join(script_dir, JSON_COMMIT_TYPE)

# Read the JSON file and extract commit types
with open(json_file_path, "r", encoding="utf-8") as f: # Specify encoding to avoid W1514
commit_types = json.load(f)
with open(json_file_path, "r", encoding="utf-8") as file:
commit_types = json.load(file)
return [commit_type.lower() for commit_type in commit_types["types"].keys()]

def validate_commit_message(message, valid_types):
Expand All @@ -43,9 +44,9 @@ def validate_commit_message(message, valid_types):
if re.match(pattern, message, re.IGNORECASE):
print("Commit message is valid.")
return True

print(f"Commit message ({message}) is invalid. Valid types are: {', '.join(valid_types)}")
return False # No need for an else block here, simplifying the code (fixing R1705)
return False

if __name__ == "__main__":
valid_commit_types = load_commit_types()
Expand Down

0 comments on commit 2840af5

Please sign in to comment.