diff options
author | Paul Ganssle <1377457+pganssle@users.noreply.github.com> | 2022-12-03 15:07:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-03 15:07:04 -0500 |
commit | b04edc08aa3559063b3b097f437941d8c4b84aba (patch) | |
tree | 174b2ef9fbd215ad01d123df9034d138a9de3f57 | |
parent | e8151c15172620d8d55e410f9297564368c886bf (diff) | |
parent | c73a9b183ff0aa2ab2ac8c7c52b61ac6081b6eed (diff) | |
download | dateutil-git-b04edc08aa3559063b3b097f437941d8c4b84aba.tar.gz |
Add pre commit
-rw-r--r-- | .github/workflows/validate.yml | 21 | ||||
-rw-r--r-- | .pre-commit-config.yaml | 14 | ||||
-rw-r--r-- | README.rst | 2 | ||||
-rw-r--r-- | pyproject.toml | 18 | ||||
-rw-r--r-- | src/dateutil/relativedelta.py | 2 | ||||
-rw-r--r-- | tests/test_isoparser.py | 8 | ||||
-rw-r--r-- | tox.ini | 10 |
7 files changed, 67 insertions, 8 deletions
diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 296da5a..cf0cdcb 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -37,7 +37,9 @@ jobs: os: "ubuntu-20.04" - python-version: "3.5" os: "ubuntu-20.04" - - python-version: "3.6" os: "ubuntu-20.04" runs-on: ${{ matrix.os }} + - python-version: "3.6" + os: "ubuntu-20.04" + runs-on: ${{ matrix.os }} env: TOXENV: py steps: @@ -76,12 +78,14 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - toxenv: ["docs", "tz"] + toxenv: ["docs", "tz", "precommit"] env: TOXENV: ${{ matrix.toxenv }} steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: ${{ matrix.toxenv }} uses: actions/setup-python@v4 with: @@ -100,6 +104,19 @@ jobs: - name: Run action run: tox + darker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + - uses: akaihola/darker@1.5.1 + with: + options: "--check --diff --color --isort" + src: "." + version: "1.5.1" + build-dist: runs-on: ubuntu-latest steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..52acb6a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +repos: + - repo: https://github.com/akaihola/darker + rev: 1.5.1 + hooks: + - id: darker + args: [--isort] + additional_dependencies: + - "isort>5.9" + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: debug-statements @@ -147,7 +147,7 @@ keys can be found below: =========== ============================ Releases Signing key fingerprint =========== ============================ -2.4.1-2.8.2 `6B49 ACBA DCF6 BD1C A206 67AB CD54 FCE3 D964 BEFB`_ +2.4.1-2.8.2 `6B49 ACBA DCF6 BD1C A206 67AB CD54 FCE3 D964 BEFB`_ =========== ============================ New releases *may* have signed tags, but binary and source distributions diff --git a/pyproject.toml b/pyproject.toml index e83d69f..67ad619 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,3 +46,21 @@ build-backend = "setuptools.build_meta" name = "Misc" showcontent = true +[tool.black] +line-length = 80 + +[tool.isort] +atomic=true +force_grid_wrap=0 +include_trailing_comma=true +known_first_party = ["dateutil"] +known_third_party=[ + "pytest", + "hypothesis", + "six", + "freezegun", + "mock", +] +multi_line_output=3 +use_parentheses=true + diff --git a/src/dateutil/relativedelta.py b/src/dateutil/relativedelta.py index a9e85f7..cd323a5 100644 --- a/src/dateutil/relativedelta.py +++ b/src/dateutil/relativedelta.py @@ -48,7 +48,7 @@ class relativedelta(object): the corresponding arithmetic operation on the original datetime value with the information in the relativedelta. - weekday: + weekday: One of the weekday instances (MO, TU, etc) available in the relativedelta module. These instances may receive a parameter N, specifying the Nth weekday, which could be positive or negative diff --git a/tests/test_isoparser.py b/tests/test_isoparser.py index 35899ab..c33881f 100644 --- a/tests/test_isoparser.py +++ b/tests/test_isoparser.py @@ -80,10 +80,10 @@ def _isoparse_date_and_time(dt, date_fmt, time_fmt, tzoffset, if not fmt.endswith('%f'): # pragma: nocover raise ValueError('Time format has no microseconds!') - if microsecond_precision != 6: - dtstr = dtstr[:-(6 - microsecond_precision)] - elif microsecond_precision > 6: # pragma: nocover - raise ValueError('Precision must be 1-6') + if microsecond_precision != 6: + dtstr = dtstr[: -(6 - microsecond_precision)] + elif microsecond_precision > 6: # pragma: nocover + raise ValueError("Precision must be 1-6") dtstr += offset_str @@ -68,6 +68,16 @@ source = dateutil skip_covered = True show_missing = True +[testenv:precommit] +description = Run the pre-commit hooks on all files +passenv = + PRE_COMMIT* +deps = + pre-commit +commands = + pre-commit install -f --install-hooks + pre-commit run --all-files + [testenv:tz] # Warning: This will modify the repository and is only intended to be run # as part of the CI process, not locally. |