Skip to content
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
94 changes: 58 additions & 36 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,54 @@
fail_fast: true
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
args:
- --py38-plus
- --keep-runtime-typing

- repo: https://github.com/ambv/black
rev: 23.11.0
rev: 24.10.0
hooks:
- id: black
language_version: python3.10

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.22
hooks:
- id: validate-pyproject

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
verbose: true
#exclude: ^tests/
entry: bash -c 'mypy "$@" || true' -- # only print
#args: [ --strict ]

- repo: https://github.com/pycqa/flake8
rev: 7.1.1 # pick a git hash / tag to point to
hooks:
- id: flake8 # stop the build if there are Python syntax errors or undefined names
additional_dependencies: [flake8-docstrings]
exclude: ^exclude*
args:
- --count
- --select=E9,F63,F7,F82
- --show-source
- --statistics
- id: flake8 # only warn
additional_dependencies: [flake8-docstrings]
exclude: ^exclude*
args:
- --count
- --exit-zero
- --max-complexity=10
- --max-line-length=127
- --statistics

- repo: local
hooks:
- id: pytest-check
Expand All @@ -13,22 +57,6 @@ repos:
language: system
pass_filenames: false
always_run: true
- repo: local
hooks:
- id: flake8-check1 # stop the build if there are Python syntax errors or undefined names
name: flake8-check1
entry: flake8 devpack --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=*exclude*
language: system
pass_filenames: false
always_run: true
- repo: local
hooks:
- id: flake8-check2 # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
name: flake8-check2
entry: flake8 devpack --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=*exclude*
language: system
pass_filenames: false
always_run: true

# - repo: local
# hooks:
Expand Down Expand Up @@ -65,7 +93,7 @@ repos:
# - id: pydocstyle

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
rev: 0.7.18
hooks:
- id: mdformat
additional_dependencies:
Expand Down Expand Up @@ -103,7 +131,7 @@ repos:

# Prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types: [yaml]
Expand All @@ -120,7 +148,7 @@ repos:
# ]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Use the ref you want to point at
rev: v5.0.0 # Use the ref you want to point at
hooks:
- id: check-added-large-files
name: check for added large files
Expand Down Expand Up @@ -162,7 +190,7 @@ repos:
entry: check-executables-have-shebangs
language: python
types: [text, executable]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
- id: check-json
name: check json
description: checks json files for parseable syntax.
Expand All @@ -175,13 +203,13 @@ repos:
entry: check-shebang-scripts-are-executable
language: python
types: [text]
stages: [commit, push, manual]
# - id: pretty-format-json
# name: pretty format json
# description: sets a standard for formatting json files.
# entry: pretty-format-json
# language: python
# types: [json]
stages: [pre-commit, pre-push, manual]
- id: pretty-format-json
name: pretty format json
description: sets a standard for formatting json files.
entry: pretty-format-json
language: python
types: [json]
- id: check-merge-conflict
name: check for merge conflicts
description: checks for files that contain merge conflict strings.
Expand Down Expand Up @@ -254,7 +282,7 @@ repos:
entry: end-of-file-fixer
language: python
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
- id: file-contents-sorter
name: file contents sorter
description: sorts the lines in specified files (defaults to alphabetical). you must provide list of target files as input in your .pre-commit-config.yaml file.
Expand All @@ -267,12 +295,6 @@ repos:
entry: fix-byte-order-marker
language: python
types: [text]
- id: fix-encoding-pragma
name: fix python encoding pragma
description: "adds # -*- coding: utf-8 -*- to the top of python files."
language: python
entry: fix-encoding-pragma
types: [python]
- id: forbid-new-submodules
name: forbid new submodules
description: prevents addition of new git submodules.
Expand Down Expand Up @@ -309,4 +331,4 @@ repos:
entry: trailing-whitespace-fixer
language: python
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
39 changes: 23 additions & 16 deletions devpack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

try:
from importlib.resources import files
from importlib.metadata import PackageNotFoundError
except (ModuleNotFoundError, ImportError) as e:
from importlib_metadata import PackageNotFoundError
from importlib_resources import files

from warg import package_is_editable, clean_string, get_version
from pathlib import Path
from apppath import AppPath
from warg import clean_string, get_version, package_is_editable

__project__ = "devpack"
__author__ = "Christian Heider Lindbjerg"
__version__ = "0.1.0"
__version__ = "0.1.1"
__doc__ = """
Created on 15/04/2020

@author: cnheider
"""

from typing import Any

__all__ = [
"PROJECT_APP_PATH",
"PROJECT_NAME",
Expand All @@ -40,12 +32,27 @@
PROJECT_APP_PATH = AppPath(app_name=PROJECT_NAME, app_author=PROJECT_AUTHOR)
PROJECT_ORGANISATION = clean_string("Pything")

PACKAGE_DATA_PATH = files(PROJECT_NAME) / "data"

import_issue_found = False
try:
DEVELOP = package_is_editable(PROJECT_NAME)
except PackageNotFoundError as e:
DEVELOP = True
from importlib.resources import files
from importlib.metadata import PackageNotFoundError
except:
try:
from importlib_metadata import PackageNotFoundError
from importlib_resources import files
except:
import_issue_found = True

if import_issue_found:
PACKAGE_DATA_PATH = Path(__file__).parent / "data"
DEVELOP = False
else:
PACKAGE_DATA_PATH = files(PROJECT_NAME) / "data"

try:
DEVELOP = package_is_editable(PROJECT_NAME)
except PackageNotFoundError as e:
DEVELOP = True

__version__ = get_version(__version__, append_time=DEVELOP)

Expand Down
1 change: 0 additions & 1 deletion devpack/batch_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand Down
6 changes: 3 additions & 3 deletions devpack/batch_tools/aliases.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


__author__ = "heider"
__doc__ = r"""
Expand All @@ -12,9 +12,9 @@
__all__ = ["recursive_detect_import_aliasing"]

from pathlib import Path
from typing import Iterable, Callable, Optional, Sequence, Mapping, List
from typing import Callable, Iterable, List, Mapping, Optional, Sequence

from warg.os_utilities.filtering import negate, is_python_package
from warg.os_utilities.filtering import is_python_package, negate


def has_import_aliases(path: Path, *, verbose: bool = False) -> bool:
Expand Down
9 changes: 4 additions & 5 deletions devpack/batch_tools/alls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


__author__ = "heider"
__doc__ = r"""
Expand All @@ -13,11 +13,11 @@

from enum import Enum
from pathlib import Path
from typing import Iterable, Callable, Optional
from typing import Callable, Iterable, Optional

from sorcery import assigned_names

from warg import is_python_package, negate, import_file
from warg import import_file, is_python_package, negate


class AutoAllsModeEnum(Enum):
Expand Down Expand Up @@ -245,8 +245,7 @@ def check_alls(path: Path, *, verbose: bool = True) -> None:
print("WARNING library file with empty __all__ declaration")


def has_multiple_alls() -> bool:
...
def has_multiple_alls() -> bool: ...


def recursive_check_alls(
Expand Down
1 change: 0 additions & 1 deletion devpack/batch_tools/authors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand Down
1 change: 0 additions & 1 deletion devpack/batch_tools/docs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand Down
1 change: 0 additions & 1 deletion devpack/batch_tools/entry_points.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand Down
3 changes: 1 addition & 2 deletions devpack/batch_tools/inits.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand All @@ -12,7 +11,7 @@
from pathlib import Path
from typing import Callable, Iterable, Optional

from warg.os_utilities.filtering import negate, is_python_module
from warg.os_utilities.filtering import is_python_module, negate


def recursive_remove_inits(
Expand Down
1 change: 1 addition & 0 deletions devpack/batch_tools/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO: CHECK FOR USE OF ROOT LOGGER! logging.info suggest replacing with logger = logging.getLogger(__name__) logger.info
4 changes: 1 addition & 3 deletions devpack/batch_tools/privates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand All @@ -12,10 +11,9 @@
__all__ = ["recursive_check_for_privates"]

from pathlib import Path
from typing import Optional, Callable, Iterable
from typing import Callable, Iterable, Optional

from draugr.os_utilities.linux_utilities.user_utilities import get_username

from warg.os_utilities.filtering import is_python_module, negate


Expand Down
3 changes: 1 addition & 2 deletions devpack/batch_tools/readmes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand All @@ -15,7 +14,7 @@

from sorcery import assigned_names

from warg.os_utilities.filtering import negate, is_python_package
from warg.os_utilities.filtering import is_python_package, negate


class TouchModeEnum(Enum):
Expand Down
1 change: 0 additions & 1 deletion devpack/batch_tools/shebangs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand Down
3 changes: 1 addition & 2 deletions devpack/batch_tools/typing_hints.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand All @@ -11,7 +10,7 @@

import subprocess
from pathlib import Path
from typing import Optional, Iterable, Callable, Sequence
from typing import Callable, Iterable, Optional, Sequence


def is_missing_typing_hints(
Expand Down
2 changes: 1 addition & 1 deletion devpack/development.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


__author__ = "Christian Heider Lindbjerg"
__doc__ = r"""
Expand Down
2 changes: 1 addition & 1 deletion devpack/entry_points/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


__author__ = "heider"
__doc__ = r"""
Expand Down
1 change: 0 additions & 1 deletion devpack/entry_points/batch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "heider"
__doc__ = r"""
Expand Down
Loading
Loading