Skip to content

Commit 61335e0

Browse files
committed
General cleanup, reformat files
* Reformat source code with black as some config options did accidently exclude the semver source code Mostly remove some includes/excludes in the black config. * Integrate concurrency in GH Action * Ignore Python files on project dirs in .gitignore * Remove unused patterns in MANIFEST.in * Use extend-exclude for flake in setup.cfg and adapt list. * Use skip_install=True in tox.ini for black
1 parent 5600d1e commit 61335e0

File tree

10 files changed

+46
-38
lines changed

10 files changed

+46
-38
lines changed

.github/workflows/python-testing.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
77
pull_request:
88
branches: [ master ]
99

10+
concurrency:
11+
# only cancel in-progress runs of the same workflow
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
# ${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
1017
jobs:
1118
check:
1219
runs-on: ubuntu-latest

.gitignore

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,12 @@ fabric.properties
259259
# --------
260260

261261

262-
# Patch/Diff Files
263-
*.patch
264-
*.diff
262+
# Ignore files in the project's root:
263+
/*.patch
264+
/*.diff
265+
/*.py
266+
# but not this file:
267+
!/setup.py
268+
265269
docs/_api
266270
!docs/_api/semver.__about__.rst

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ include tests/test_*.py
55
prune docs/_build
66
recursive-exclude .github *
77

8-
global-exclude *.py[cod] __pycache__ *.so *.dylib
8+
global-exclude __pycache__

changelog.d/pr384.bugfix.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
General cleanup, reformat files:
2+
3+
* Reformat source code with black again as some config options
4+
did accidentely exclude the semver source code.
5+
Mostly remove some includes/excludes in the black config.
6+
* Integrate concurrency in GH Action
7+
* Ignore Python files on project dirs in .gitignore
8+
* Remove unused patterns in MANIFEST.in
9+
* Use ``extend-exclude`` for flake in :file:`setup.cfg`` and adapt list.
10+
* Use ``skip_install=True`` in :file:`tox.ini` for black
11+

docs/advanced/semverwithvprefix.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ def parse(cls, version: str) -> "SemVerWithVPrefix":
1717
"""
1818
if not version[0] in ("v", "V"):
1919
raise ValueError(
20-
"{v!r}: not a valid semantic version tag. "
21-
"Must start with 'v' or 'V'".format(
22-
v=version
23-
)
20+
f"{version!r}: not a valid semantic version tag. "
21+
"Must start with 'v' or 'V'"
2422
)
2523
return super().parse(version[1:])
2624

pyproject.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@ build-backend = "setuptools.build_meta"
2121
line-length = 88
2222
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
2323
# diff = true
24-
extend-exclude = '''
25-
# A regex preceded with ^/ will apply only to files and directories
26-
# in the root of the project.
27-
^/*.py
28-
'''
29-
include = '''
30-
^/setup.py
31-
'''
24+
3225

3326
[tool.towncrier]
3427
package = "semver"

setup.cfg

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ semver = py.typed
5555
[tool:pytest]
5656
norecursedirs = .git build .env/ env/ .pyenv/ .tmp/ .eggs/ venv/
5757
testpaths = tests docs
58+
# pythonpath = src
5859
filterwarnings =
5960
ignore:Function 'semver.*:DeprecationWarning
6061
# ' <- This apostroph is just to fix syntax highlighting
6162
addopts =
63+
# --import-mode=importlib
6264
--no-cov-on-fail
6365
--cov=semver
6466
--cov-report=term-missing
@@ -69,18 +71,15 @@ addopts =
6971
[flake8]
7072
max-line-length = 88
7173
ignore = F821,W503
72-
exclude =
73-
src/semver/__init__.py
74-
.env
75-
venv
74+
extend-exclude =
7675
.eggs
77-
.tox
78-
.git
79-
__pycache__
76+
.env
8077
build
81-
dist
8278
docs
79+
venv
8380
conftest.py
81+
src/semver/__init__.py
82+
tasks.py
8483

8584
[pycodestyle]
8685
count = False

src/semver/version.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ class Version:
6969
#: Regex for number in a prerelease
7070
_LAST_NUMBER = re.compile(r"(?:[^\d]*(\d+)[^\d]*)+")
7171
#: Regex template for a semver version
72-
_REGEX_TEMPLATE = \
73-
r"""
72+
_REGEX_TEMPLATE = r"""
7473
^
7574
(?P<major>0|[1-9]\d*)
7675
(?:
@@ -93,12 +92,12 @@ class Version:
9392
"""
9493
#: Regex for a semver version
9594
_REGEX = re.compile(
96-
_REGEX_TEMPLATE.format(opt_patch='', opt_minor=''),
95+
_REGEX_TEMPLATE.format(opt_patch="", opt_minor=""),
9796
re.VERBOSE,
9897
)
9998
#: Regex for a semver version that might be shorter
10099
_REGEX_OPTIONAL_MINOR_AND_PATCH = re.compile(
101-
_REGEX_TEMPLATE.format(opt_patch='?', opt_minor='?'),
100+
_REGEX_TEMPLATE.format(opt_patch="?", opt_minor="?"),
102101
re.VERBOSE,
103102
)
104103

@@ -571,9 +570,7 @@ def match(self, match_expr: str) -> bool:
571570

572571
@classmethod
573572
def parse(
574-
cls,
575-
version: String,
576-
optional_minor_and_patch: bool = False
573+
cls, version: String, optional_minor_and_patch: bool = False
577574
) -> "Version":
578575
"""
579576
Parse version string to a Version instance.
@@ -611,10 +608,10 @@ def parse(
611608
raise ValueError(f"{version} is not valid SemVer string")
612609

613610
matched_version_parts: Dict[str, Any] = match.groupdict()
614-
if not matched_version_parts['minor']:
615-
matched_version_parts['minor'] = 0
616-
if not matched_version_parts['patch']:
617-
matched_version_parts['patch'] = 0
611+
if not matched_version_parts["minor"]:
612+
matched_version_parts["minor"] = 0
613+
if not matched_version_parts["patch"]:
614+
matched_version_parts["patch"] = 0
618615

619616
return cls(**matched_version_parts)
620617

tests/test_match.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ def test_should_raise_value_error_for_unexpected_match_expression(left, right):
6060
match(left, right)
6161

6262

63-
@pytest.mark.parametrize(
64-
"left,right", [("1.0.0", ""), ("1.0.0", "!")]
65-
)
63+
@pytest.mark.parametrize("left,right", [("1.0.0", ""), ("1.0.0", "!")])
6664
def test_should_raise_value_error_for_invalid_match_expression(left, right):
6765
with pytest.raises(ValueError):
6866
match(left, right)

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ setenv =
3232
[testenv:black]
3333
description = Check for formatting changes
3434
basepython = python3
35+
skip_install = true
3536
deps = black
3637
commands = black --check {posargs:.}
3738

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy