Skip to content

Commit e093e1f

Browse files
authored
Merge pull request #5 from pything/develop
--no-verify
2 parents 7e67bec + 926a7a1 commit e093e1f

26 files changed

Lines changed: 102 additions & 95 deletions

.pre-commit-config.yaml

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,54 @@
11
fail_fast: true
22
repos:
3+
- repo: https://github.com/asottile/pyupgrade
4+
rev: v3.19.0
5+
hooks:
6+
- id: pyupgrade
7+
args:
8+
- --py38-plus
9+
- --keep-runtime-typing
10+
311
- repo: https://github.com/ambv/black
4-
rev: 23.11.0
12+
rev: 24.10.0
513
hooks:
614
- id: black
715
language_version: python3.10
16+
17+
- repo: https://github.com/abravalheri/validate-pyproject
18+
rev: v0.22
19+
hooks:
20+
- id: validate-pyproject
21+
22+
- repo: https://github.com/pre-commit/mirrors-mypy
23+
rev: v1.13.0
24+
hooks:
25+
- id: mypy
26+
verbose: true
27+
#exclude: ^tests/
28+
entry: bash -c 'mypy "$@" || true' -- # only print
29+
#args: [ --strict ]
30+
31+
- repo: https://github.com/pycqa/flake8
32+
rev: 7.1.1 # pick a git hash / tag to point to
33+
hooks:
34+
- id: flake8 # stop the build if there are Python syntax errors or undefined names
35+
additional_dependencies: [flake8-docstrings]
36+
exclude: ^exclude*
37+
args:
38+
- --count
39+
- --select=E9,F63,F7,F82
40+
- --show-source
41+
- --statistics
42+
- id: flake8 # only warn
43+
additional_dependencies: [flake8-docstrings]
44+
exclude: ^exclude*
45+
args:
46+
- --count
47+
- --exit-zero
48+
- --max-complexity=10
49+
- --max-line-length=127
50+
- --statistics
51+
852
- repo: local
953
hooks:
1054
- id: pytest-check
@@ -13,22 +57,6 @@ repos:
1357
language: system
1458
pass_filenames: false
1559
always_run: true
16-
- repo: local
17-
hooks:
18-
- id: flake8-check1 # stop the build if there are Python syntax errors or undefined names
19-
name: flake8-check1
20-
entry: flake8 devpack --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=*exclude*
21-
language: system
22-
pass_filenames: false
23-
always_run: true
24-
- repo: local
25-
hooks:
26-
- id: flake8-check2 # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
27-
name: flake8-check2
28-
entry: flake8 devpack --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=*exclude*
29-
language: system
30-
pass_filenames: false
31-
always_run: true
3260

3361
# - repo: local
3462
# hooks:
@@ -65,7 +93,7 @@ repos:
6593
# - id: pydocstyle
6694

6795
- repo: https://github.com/executablebooks/mdformat
68-
rev: 0.7.17
96+
rev: 0.7.18
6997
hooks:
7098
- id: mdformat
7199
additional_dependencies:
@@ -103,7 +131,7 @@ repos:
103131

104132
# Prettier
105133
- repo: https://github.com/pre-commit/mirrors-prettier
106-
rev: v3.1.0
134+
rev: v4.0.0-alpha.8
107135
hooks:
108136
- id: prettier
109137
types: [yaml]
@@ -120,7 +148,7 @@ repos:
120148
# ]
121149

122150
- repo: https://github.com/pre-commit/pre-commit-hooks
123-
rev: v4.5.0 # Use the ref you want to point at
151+
rev: v5.0.0 # Use the ref you want to point at
124152
hooks:
125153
- id: check-added-large-files
126154
name: check for added large files
@@ -162,7 +190,7 @@ repos:
162190
entry: check-executables-have-shebangs
163191
language: python
164192
types: [text, executable]
165-
stages: [commit, push, manual]
193+
stages: [pre-commit, pre-push, manual]
166194
- id: check-json
167195
name: check json
168196
description: checks json files for parseable syntax.
@@ -175,13 +203,13 @@ repos:
175203
entry: check-shebang-scripts-are-executable
176204
language: python
177205
types: [text]
178-
stages: [commit, push, manual]
179-
# - id: pretty-format-json
180-
# name: pretty format json
181-
# description: sets a standard for formatting json files.
182-
# entry: pretty-format-json
183-
# language: python
184-
# types: [json]
206+
stages: [pre-commit, pre-push, manual]
207+
- id: pretty-format-json
208+
name: pretty format json
209+
description: sets a standard for formatting json files.
210+
entry: pretty-format-json
211+
language: python
212+
types: [json]
185213
- id: check-merge-conflict
186214
name: check for merge conflicts
187215
description: checks for files that contain merge conflict strings.
@@ -254,7 +282,7 @@ repos:
254282
entry: end-of-file-fixer
255283
language: python
256284
types: [text]
257-
stages: [commit, push, manual]
285+
stages: [pre-commit, pre-push, manual]
258286
- id: file-contents-sorter
259287
name: file contents sorter
260288
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.
@@ -267,12 +295,6 @@ repos:
267295
entry: fix-byte-order-marker
268296
language: python
269297
types: [text]
270-
- id: fix-encoding-pragma
271-
name: fix python encoding pragma
272-
description: "adds # -*- coding: utf-8 -*- to the top of python files."
273-
language: python
274-
entry: fix-encoding-pragma
275-
types: [python]
276298
- id: forbid-new-submodules
277299
name: forbid new submodules
278300
description: prevents addition of new git submodules.
@@ -309,4 +331,4 @@ repos:
309331
entry: trailing-whitespace-fixer
310332
language: python
311333
types: [text]
312-
stages: [commit, push, manual]
334+
stages: [pre-commit, pre-push, manual]

devpack/__init__.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

4-
try:
5-
from importlib.resources import files
6-
from importlib.metadata import PackageNotFoundError
7-
except (ModuleNotFoundError, ImportError) as e:
8-
from importlib_metadata import PackageNotFoundError
9-
from importlib_resources import files
103

11-
from warg import package_is_editable, clean_string, get_version
4+
from pathlib import Path
125
from apppath import AppPath
6+
from warg import clean_string, get_version, package_is_editable
137

148
__project__ = "devpack"
159
__author__ = "Christian Heider Lindbjerg"
16-
__version__ = "0.1.0"
10+
__version__ = "0.1.1"
1711
__doc__ = """
1812
Created on 15/04/2020
1913
2014
@author: cnheider
2115
"""
2216

23-
from typing import Any
24-
2517
__all__ = [
2618
"PROJECT_APP_PATH",
2719
"PROJECT_NAME",
@@ -40,12 +32,27 @@
4032
PROJECT_APP_PATH = AppPath(app_name=PROJECT_NAME, app_author=PROJECT_AUTHOR)
4133
PROJECT_ORGANISATION = clean_string("Pything")
4234

43-
PACKAGE_DATA_PATH = files(PROJECT_NAME) / "data"
44-
35+
import_issue_found = False
4536
try:
46-
DEVELOP = package_is_editable(PROJECT_NAME)
47-
except PackageNotFoundError as e:
48-
DEVELOP = True
37+
from importlib.resources import files
38+
from importlib.metadata import PackageNotFoundError
39+
except:
40+
try:
41+
from importlib_metadata import PackageNotFoundError
42+
from importlib_resources import files
43+
except:
44+
import_issue_found = True
45+
46+
if import_issue_found:
47+
PACKAGE_DATA_PATH = Path(__file__).parent / "data"
48+
DEVELOP = False
49+
else:
50+
PACKAGE_DATA_PATH = files(PROJECT_NAME) / "data"
51+
52+
try:
53+
DEVELOP = package_is_editable(PROJECT_NAME)
54+
except PackageNotFoundError as e:
55+
DEVELOP = True
4956

5057
__version__ = get_version(__version__, append_time=DEVELOP)
5158

devpack/batch_tools/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
__author__ = "heider"
54
__doc__ = r"""

devpack/batch_tools/aliases.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
2+
33

44
__author__ = "heider"
55
__doc__ = r"""
@@ -12,9 +12,9 @@
1212
__all__ = ["recursive_detect_import_aliasing"]
1313

1414
from pathlib import Path
15-
from typing import Iterable, Callable, Optional, Sequence, Mapping, List
15+
from typing import Callable, Iterable, List, Mapping, Optional, Sequence
1616

17-
from warg.os_utilities.filtering import negate, is_python_package
17+
from warg.os_utilities.filtering import is_python_package, negate
1818

1919

2020
def has_import_aliases(path: Path, *, verbose: bool = False) -> bool:

devpack/batch_tools/alls.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
2+
33

44
__author__ = "heider"
55
__doc__ = r"""
@@ -13,11 +13,11 @@
1313

1414
from enum import Enum
1515
from pathlib import Path
16-
from typing import Iterable, Callable, Optional
16+
from typing import Callable, Iterable, Optional
1717

1818
from sorcery import assigned_names
1919

20-
from warg import is_python_package, negate, import_file
20+
from warg import import_file, is_python_package, negate
2121

2222

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

247247

248-
def has_multiple_alls() -> bool:
249-
...
248+
def has_multiple_alls() -> bool: ...
250249

251250

252251
def recursive_check_alls(

devpack/batch_tools/authors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
__author__ = "heider"
54
__doc__ = r"""

devpack/batch_tools/docs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
__author__ = "heider"
54
__doc__ = r"""

devpack/batch_tools/entry_points.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
__author__ = "heider"
54
__doc__ = r"""

devpack/batch_tools/inits.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
__author__ = "heider"
54
__doc__ = r"""
@@ -12,7 +11,7 @@
1211
from pathlib import Path
1312
from typing import Callable, Iterable, Optional
1413

15-
from warg.os_utilities.filtering import negate, is_python_module
14+
from warg.os_utilities.filtering import is_python_module, negate
1615

1716

1817
def recursive_remove_inits(

devpack/batch_tools/logging.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO: CHECK FOR USE OF ROOT LOGGER! logging.info suggest replacing with logger = logging.getLogger(__name__) logger.info

0 commit comments

Comments
 (0)