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

chore: add ruff for code formatting #61

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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