-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci should work now * fix a pyright error * ci uses pre-commit for checks * fixed requirements * fix dependency * add all the optional packaged to CI
- Loading branch information
1 parent
65d65b9
commit 02bd211
Showing
34 changed files
with
688 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
repos: | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.0.275 | ||
- repo: local | ||
hooks: | ||
- id: ruff | ||
args: [ --fix, --exit-non-zero-on-fix ] | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
name: isort (python) | ||
|
||
- repo: https://github.com/psf/black.git | ||
rev: 23.1.0 | ||
hooks: | ||
- id: black | ||
language_version: python3.9 | ||
|
||
- id: generate-init | ||
name: Generates __init__.py files | ||
language: python | ||
entry: python hooks/generate_init.py | ||
always_run: true | ||
require_serial: true | ||
additional_dependencies: ["mkinit", "ruff"] | ||
|
||
- id: fix-line-endings | ||
name: Convert CRLF/CR endings to LF | ||
language: python | ||
require_serial: true | ||
entry: python hooks/fix_line_endings.py | ||
types: ["text"] | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
rev: v4.6.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: fix-encoding-pragma | ||
- id: trailing-whitespace | ||
- id: check-case-conflict | ||
- id: check-executables-have-shebangs | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: debug-statements | ||
- id: mixed-line-ending | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.4.6 | ||
hooks: | ||
#Run the formatter. | ||
- id: ruff-format | ||
types_or: [ python, pyi, jupyter ] | ||
#Run the linter. | ||
- id: ruff | ||
types_or: [ python, pyi, jupyter ] | ||
args: [ --fix, --exit-non-zero-on-fix ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
from __future__ import annotations | ||
|
||
import argparse | ||
from pathlib import Path | ||
import sys | ||
|
||
|
||
def main(source_path: str) -> bool: | ||
""" | ||
Main entry point of the script. | ||
Parameters | ||
---------- | ||
function : Callable | ||
Function to execute for the specified validation type. | ||
source_path : str | ||
Source path representing path to a file/directory. | ||
output_format : str | ||
Output format of the error message. | ||
file_extensions_to_check : str | ||
Comma separated values of what file extensions to check. | ||
excluded_file_paths : str | ||
Comma separated values of what file paths to exclude during the check. | ||
Returns | ||
------- | ||
bool | ||
True if found any patterns are found related to the given function. | ||
Raises | ||
------ | ||
ValueError | ||
If the `source_path` is not pointing to existing file/directory. | ||
""" | ||
|
||
for file_path in source_path: | ||
with Path(file_path).open("r", encoding="utf-8") as file_obj: | ||
file_text = file_obj.read() | ||
|
||
invalid_ending = "\r" in file_text | ||
if invalid_ending: | ||
with Path(file_path).open("w", encoding="utf-8") as file_obj: | ||
file_obj.write(file_text) | ||
|
||
return invalid_ending | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="CR/CRLF -> LF converter.") | ||
|
||
parser.add_argument("paths", nargs="*", help="Source paths of files to check.") | ||
|
||
args = parser.parse_args() | ||
|
||
sys.exit(main(source_path=args.paths)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
from __future__ import annotations | ||
|
||
import subprocess | ||
import sys | ||
|
||
from mkinit import static_mkinit | ||
|
||
|
||
def ruff_format(): ... | ||
def make_init(): | ||
options = { | ||
"with_attrs": True, | ||
"with_mods": True, | ||
"with_all": True, | ||
"relative": True, | ||
"lazy_import": False, | ||
"lazy_loader": True, | ||
"lazy_loader_typed": True, | ||
"lazy_boilerplate": None, | ||
"use_black": False, | ||
} | ||
|
||
static_mkinit.autogen_init( | ||
"prepper", | ||
respect_all=True, | ||
options=options, | ||
dry=False, | ||
diff=False, | ||
recursive=True, | ||
) | ||
subprocess.run(["ruff", "format"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
make_init() | ||
|
||
changed_files1 = subprocess.run( | ||
["git", "diff", "--name-only", "--diff-filter=ACM", "--exit-code"] | ||
) | ||
changed_files2 = subprocess.run( | ||
["git", "ls-files", "--exclude-standard", "--others"], capture_output=True | ||
) | ||
retcode = changed_files1.returncode + changed_files2.returncode | ||
retcode += len(changed_files2.stderr) | ||
retcode += len(changed_files2.stdout) | ||
|
||
sys.exit(retcode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,53 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import annotations | ||
|
||
import h5py | ||
__protected__ = ["utils", "io_handlers", "enums", "utils"] | ||
|
||
|
||
# <AUTOGEN_INIT> | ||
import lazy_loader | ||
|
||
|
||
__getattr__, __dir__, __all__ = lazy_loader.attach_stub(__name__, __file__) | ||
|
||
__all__ = [ | ||
"ExportableClassMixin", | ||
"H5StoreException", | ||
"NATIVE_DTYPES", | ||
"NotASaveableClass", | ||
"SimpleSaveableClass", | ||
"SimpleSaveableClass2", | ||
"break_key", | ||
"cached_property", | ||
"caching", | ||
"ensure_required_attributes", | ||
"enums", | ||
"exceptions", | ||
"exportable", | ||
"io_handlers", | ||
"local_cache", | ||
"ExportableClassMixin", | ||
"make_cache_name", | ||
"req_class_attrs", | ||
"req_dataset_attrs", | ||
"req_none_attrs", | ||
"roundtrip", | ||
"saveable_class", | ||
"test_IO", | ||
"test_cached_property", | ||
"test_decorators", | ||
"test_local_cache", | ||
"test_saveable_class", | ||
"test_with_float_list", | ||
"test_with_floats", | ||
"test_with_heterogenous_list", | ||
"test_with_int_list", | ||
"test_with_ints", | ||
"test_with_str_list", | ||
"tests", | ||
"utils", | ||
] | ||
# </AUTOGEN_INIT> | ||
|
||
import h5py | ||
|
||
# Make h5py write groups in order | ||
h5py.get_config().track_order = True | ||
|
||
|
||
class H5StoreException(Exception): | ||
"An exception for when the HDF5 store does not meet spec" | ||
|
||
|
||
from .caching import cached_property, local_cache # noqa E402 | ||
from .exportable import ExportableClassMixin, saveable_class # noqa E402 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from . import caching | ||
from . import enums | ||
from . import exceptions | ||
from . import exportable | ||
from . import io_handlers | ||
from . import tests | ||
from . import utils | ||
|
||
from .caching import ( | ||
break_key, | ||
cached_property, | ||
local_cache, | ||
make_cache_name, | ||
) | ||
from .exceptions import ( | ||
H5StoreException, | ||
) | ||
from .exportable import ( | ||
ExportableClassMixin, | ||
saveable_class, | ||
) | ||
from .tests import ( | ||
NATIVE_DTYPES, | ||
NotASaveableClass, | ||
SimpleSaveableClass, | ||
SimpleSaveableClass2, | ||
ensure_required_attributes, | ||
req_class_attrs, | ||
req_dataset_attrs, | ||
req_none_attrs, | ||
roundtrip, | ||
test_IO, | ||
test_cached_property, | ||
test_decorators, | ||
test_local_cache, | ||
test_saveable_class, | ||
test_with_float_list, | ||
test_with_floats, | ||
test_with_heterogenous_list, | ||
test_with_int_list, | ||
test_with_ints, | ||
test_with_str_list, | ||
) | ||
|
||
__all__ = [ | ||
"ExportableClassMixin", | ||
"H5StoreException", | ||
"NATIVE_DTYPES", | ||
"NotASaveableClass", | ||
"SimpleSaveableClass", | ||
"SimpleSaveableClass2", | ||
"break_key", | ||
"cached_property", | ||
"caching", | ||
"ensure_required_attributes", | ||
"enums", | ||
"exceptions", | ||
"exportable", | ||
"io_handlers", | ||
"local_cache", | ||
"make_cache_name", | ||
"req_class_attrs", | ||
"req_dataset_attrs", | ||
"req_none_attrs", | ||
"roundtrip", | ||
"saveable_class", | ||
"test_IO", | ||
"test_cached_property", | ||
"test_decorators", | ||
"test_local_cache", | ||
"test_saveable_class", | ||
"test_with_float_list", | ||
"test_with_floats", | ||
"test_with_heterogenous_list", | ||
"test_with_int_list", | ||
"test_with_ints", | ||
"test_with_str_list", | ||
"tests", | ||
"utils", | ||
] |
Oops, something went wrong.