Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 239efcc

Browse files
Remi-Gauyibeichanpre-commit-ci[bot]
authoredJun 21, 2024··
[ENH] package with pyproject.tom and lint (#46)
* package with pyproject.toml, add isort / codespell, apply linting via pre-commit * update pre-commit * run tests * rm breakpoints * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_rs2redcap_redcap2rs.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Yibei Chen <yibeichan@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 05362e8 commit 239efcc

30 files changed

+411
-3317
lines changed
 

‎.flake8

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[flake8]
2+
doctests = True
3+
exclude =
4+
**/__init__.py
5+
**/tests/*
6+
*build/
7+
docs/sphinxext/
8+
docs/tools/
9+
reproschema/_version.py
10+
max-line-length=79
11+
extend-ignore = B001, B006, B016, E501, E722, F821

‎.gitattributes

-1
This file was deleted.

‎.github/workflows/pythonpackage.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Python package
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches: [ main ]
99
pull_request:
10-
branches: [ master ]
10+
branches: [ main ]
1111

1212
jobs:
1313
build:

‎.github/workflows/pythonpublish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ jobs:
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
24-
pip install setuptools wheel twine pyyaml
24+
pip install setuptools twine pyyaml build
2525
- name: Build and publish
2626
env:
2727
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2828
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
2929
run: |
30-
python setup.py bdist_wheel
30+
python -m build
3131
twine upload dist/*

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# autogenerated by hacthling
2+
reproschema/_version.py
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

‎.pre-commit-config.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,43 @@ repos:
88
- id: end-of-file-fixer
99
- id: check-yaml
1010
- id: check-added-large-files
11+
12+
# Sorts Python imports alphabetically and by section with `isort`.
13+
- repo: https://github.com/pycqa/isort
14+
rev: 5.13.2
15+
hooks:
16+
- id: isort
17+
args: [--profile, black, --settings-path, pyproject.toml]
18+
1119
- repo: https://github.com/psf/black
1220
rev: 24.4.2
1321
hooks:
1422
- id: black
23+
24+
# Checks for spelling errors
25+
- repo: https://github.com/codespell-project/codespell
26+
rev: v2.3.0
27+
hooks:
28+
- id: codespell
29+
args: [--toml, pyproject.toml]
30+
additional_dependencies: [tomli]
31+
32+
# Format TOML files
33+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
34+
rev: v2.13.0
35+
hooks:
36+
- id: pretty-format-toml
37+
args: [--autofix, --indent, '4']
38+
39+
# Check that Python code complies with PEP8 guidelines
40+
# flake8 uses pydocstyle to check docstrings: https://flake8.pycqa.org/en/latest/
41+
# flake8-docstrings: https://pypi.org/project/flake8-docstrings/
42+
# flake8-use-fstring forces to use fstrings: https://pypi.org/project/flake8-use-fstring/
43+
# flake8-functions checks functions quality: https://pypi.org/project/flake8-functions/
44+
# flake8-bugbear detects some common bugs: https://github.com/PyCQA/flake8-bugbear
45+
- repo: https://github.com/pyCQA/flake8
46+
rev: 7.1.0
47+
hooks:
48+
- id: flake8
49+
args: [--config, .flake8, --verbose, reproschema]
50+
additional_dependencies: [flake8-bugbear]

‎codespell_ignore_words.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
datas
2+
Varios
3+
deamon

‎pyproject.toml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
[build-system]
2+
build-backend = "hatchling.build"
3+
requires = ["hatchling", "hatch-vcs"]
4+
5+
[project]
6+
authors = [{name = "Repronim developers", email = "info@repronim.org"}]
7+
dependencies = [
8+
"click",
9+
"etelemetry",
10+
"pyshacl",
11+
"PyLD",
12+
"requests",
13+
"requests_cache",
14+
"pyyaml",
15+
"beautifulsoup4",
16+
"lxml",
17+
"pydantic >= 2.0"
18+
]
19+
description = "Reproschema Python library"
20+
# Version from setuptools_scm
21+
dynamic = ["version"]
22+
license = {text = "Apache License, 2.0"}
23+
maintainers = [{name = "Repronim developers", email = "info@repronim.org"}]
24+
name = "reproschema-py"
25+
readme = "README.md"
26+
requires-python = ">=3.8"
27+
28+
[project.optional-dependencies]
29+
all = ["reproschema-py[doc]", "reproschema-py[test]"]
30+
dev = ["reproschema-py[doc]", "reproschema-py[test]", "black", "pre-commit"]
31+
doc = [
32+
"packaging",
33+
"sphinx >= 2.1.2",
34+
"sphinx_rtd_theme",
35+
"sphinxcontrib-apidoc ~= 0.3.0",
36+
"sphinxcontrib-napoleon",
37+
"sphinxcontrib-versioning"
38+
]
39+
docs = ["reproschema-py[doc]"]
40+
# For running unit and docstring tests
41+
test = [
42+
"pytest >= 4.4.0",
43+
"pytest-cov",
44+
"pytest-env",
45+
"pytest-xdist",
46+
"pytest-rerunfailures",
47+
"codecov"
48+
]
49+
tests = ["reproschema-py[test]"]
50+
51+
[project.scripts]
52+
reproschema = "reproschema.cli:main"
53+
54+
[project.urls]
55+
Homepage = "https://github.com/ReproNim/reproschema-py"
56+
57+
[tool.black]
58+
line-length = 79
59+
60+
[tool.codespell]
61+
ignore-words = "codespell_ignore_words.txt"
62+
skip = "./.git"
63+
64+
[tool.hatch.build.hooks.vcs]
65+
version-file = "reproschema/_version.py"
66+
67+
[tool.hatch.build.targets.wheel]
68+
packages = ["reproschema"]
69+
70+
[tool.hatch.version]
71+
source = "vcs"
72+
73+
[tool.isort]
74+
combine_as_imports = true
75+
line_length = 79
76+
profile = "black"
77+
skip_gitignore = true
78+
79+
[tool.pytest.ini_options]
80+
addopts = "-ra --strict-config --strict-markers --doctest-modules --showlocals -v"
81+
doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS"
82+
junit_family = "xunit2"
83+
minversion = "6.0"
84+
xfail_strict = true

‎reproschema/__init__.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import logging
22
import os
33

4-
from ._version import get_versions
5-
6-
__version__ = get_versions()["version"]
7-
del get_versions
4+
from reproschema._version import __version__
85

96
#
107
# Basic logger configuration
@@ -40,12 +37,11 @@ def set_logger_level(lgr, level):
4037
try:
4138
import etelemetry
4239

43-
etelemetry.check_available_version("repronim/reproschema-py", __version__, lgr=lgr)
40+
etelemetry.check_available_version(
41+
"repronim/reproschema-py", __version__, lgr=lgr
42+
)
4443
except Exception as exc:
4544
lgr.warning(
46-
"Failed to check for a more recent version available with etelemetry: %s", exc
45+
"Failed to check for a more recent version available with etelemetry: %s",
46+
exc,
4747
)
48-
49-
from . import _version
50-
51-
__version__ = _version.get_versions()["version"]

0 commit comments

Comments
 (0)