Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
Add ruff pre-commit check for Python code
Browse files Browse the repository at this point in the history
  • Loading branch information
larsks committed Feb 13, 2024
1 parent 0b7be8e commit 94db039
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ repos:
types: [file, yaml]
entry: yamllint --strict

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: ruff
- id: ruff-format

- repo: local
hooks:
- id: jsonnetfmt
Expand Down
9 changes: 4 additions & 5 deletions vault_config/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@

from pathlib import Path
from fnmatch import fnmatch
from contextlib import contextmanager

from .exceptions import InvalidFileTypeError

LOG = logging.getLogger(__name__)


class Loader:
'''Load serialized data into a local cache.'''
"""Load serialized data into a local cache."""

def __init__(self, import_directories=None):
self.import_directories = import_directories or []
Expand All @@ -32,7 +31,7 @@ def __exit__(self, *args):
self.tmpdir = None

def import_callback(self, parent, path):
'''Resolve jsonnet imports'''
"""Resolve jsonnet imports"""

LOG.debug("jsonnet import %s", path)
for importdir in [parent] + self.import_directories:
Expand Down Expand Up @@ -75,13 +74,13 @@ def load_jsonnet_file(self, path):
return json.loads(content)

def load(self, path):
'''Load a document into our local cache.
"""Load a document into our local cache.
This function unmarshals the given path into a Python data
structure, and then writes it out as a JSON file in self.tmpdir.
This pre-processing ensures that the files are syntactically
correct and that any dependencies can be successfully resolved.
'''
"""

LOG.debug("loading %s", path)
if fnmatch(path, "*.j2.yaml"):
Expand Down

0 comments on commit 94db039

Please sign in to comment.