Skip to content

Commit

Permalink
chore: add ruff for code formatting (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
lumasepa authored Nov 26, 2024
1 parent 5098d7b commit 9a165fd
Show file tree
Hide file tree
Showing 17 changed files with 785 additions and 590 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:
version: "0.4.24"
- name: Install dependencies
run: uv sync --all-extras --dev

- name: Format check
run: make format-check
- name: Lint with pylint
run: |
uv run pylint nada_dsl/
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ release:
lint:
uv run pylint nada_dsl/

format:
uv run ruff format

format-check:
uv run ruff format --check

# TODO fix all check errors
ruff-check:
uv run ruff check

test-dependencies:
pip install .'[test]'

Expand Down
3 changes: 1 addition & 2 deletions nada_dsl/ast_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" AST utilities."""
"""AST utilities."""

from abc import ABC
from dataclasses import dataclass
Expand Down Expand Up @@ -94,7 +94,6 @@ def child_operations(self):
return [self.child]

def to_mir(self):

return {
self.name: {
"id": self.id,
Expand Down
10 changes: 6 additions & 4 deletions nada_dsl/audit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
"""Export classes and functions for Nada DSL auditing component."""

import argparse

from nada_dsl.audit.abstract import *
from nada_dsl.audit.report import html
from nada_dsl.audit.strict import strict


def _main():
parser = argparse.ArgumentParser()
parser.add_argument('path', nargs=1, help='Nada DSL source file path')
parser.add_argument('--strict', action='store_true', required=True)
parser.add_argument("path", nargs=1, help="Nada DSL source file path")
parser.add_argument("--strict", action="store_true", required=True)
args = parser.parse_args()
path = args.path[0]

with open(path, 'r', encoding='UTF-8') as file:
with open(path, "r", encoding="UTF-8") as file:
source = file.read()
report = strict(source)

with open(path[:-2] + 'html', 'w', encoding='UTF-8') as file:
with open(path[:-2] + "html", "w", encoding="UTF-8") as file:
file.write(html(report))
2 changes: 2 additions & 0 deletions nada_dsl/audit/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Execute the command line interface entry point."""

from nada_dsl.audit import _main

_main()
Loading

0 comments on commit 9a165fd

Please sign in to comment.