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

[STY] add isort and flake8 and run pre-commit on all files #512

Merged
merged 1 commit into from
Jun 18, 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
4 changes: 0 additions & 4 deletions .codespellrc

This file was deleted.

4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length=79
exclude =
scripts/editProperties.py
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,29 @@ repos:
- id: check-ast
- id: check-added-large-files
- id: check-merge-conflict

# Sorts Python imports alphabetically and by section with `isort`.
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: [--settings-path, pyproject.toml]

- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [--toml, pyproject.toml]
additional_dependencies: [tomli]

- repo: https://github.com/pyCQA/flake8
rev: 7.1.0
hooks:
- id: flake8
args: [--config, .flake8, --verbose]
additional_dependencies: [flake8-bugbear]
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.black]
line-length = 79

[tool.codespell]
skip = "env,venv,*.svg,pyproject.toml"
ignore-words-list = "HSI"
builtin = "clear,rare"

[tool.isort]
combine_as_imports = true
line_length = 79
profile = "black"
skip_gitignore = true
7 changes: 6 additions & 1 deletion scripts/editProperties.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys

import rdflib as rl
from pytablewriter import MarkdownTableWriter

Expand Down Expand Up @@ -81,7 +82,11 @@ def edit_properties(version):
writer.value_matrix = []
del props["klass_desc"]
for val, comment in sorted(props.items()):
property = [val[2], comment, f"[{val[1]}{val[2]}]({val[1]}{val[2]})"]
property = [
val[2],
comment,
f"[{val[1]}{val[2]}]({val[1]}{val[2]})",
]
writer.value_matrix.append(property)
writer.margin = 1 # add a whitespace for both sides of each cell
doc.append("\n")
Expand Down
4 changes: 2 additions & 2 deletions scripts/jsonParser.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import json
import os

schema_dirs = ["contexts", "schemas", "terms"]
tested = 0
for root, dirs, files in os.walk(".", topdown=True):
for root, _, files in os.walk(".", topdown=True):
if os.path.basename(root) in schema_dirs:
for name in files:
with open(os.path.join(root, name)) as fp:
Expand Down
12 changes: 8 additions & 4 deletions scripts/makeRelease.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import json
import os
import sys
import json
from pyld import jsonld
import rdflib as rl
from shutil import copyfile

import rdflib as rl
from pyld import jsonld

from reproschema.jsonldutils import to_newformat


Expand All @@ -12,7 +14,9 @@ def create_release(version):
terms = []
for root, _, files in os.walk("terms"):
for name in files:
terms.extend(json.loads(to_newformat(os.path.join(root, name), "jsonld")))
terms.extend(
json.loads(to_newformat(os.path.join(root, name), "jsonld"))
)

kwargs = {"algorithm": "URDNA2015", "format": "application/n-quads"}
data = jsonld.normalize(terms, kwargs)
Expand Down
Loading