Skip to content
This repository was archived by the owner on Jun 2, 2022. It is now read-only.

Commit 7ef69b0

Browse files
authored
Merge pull request #1 from python-poetry/linting
Add linting checks
2 parents adbe427 + 906a0e1 commit 7ef69b0

File tree

11 files changed

+63
-9
lines changed

11 files changed

+63
-9
lines changed

.flake8

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[flake8]
2+
max-line-length = 88
3+
ignore = E501, E203, W503
4+
per-file-ignores = __init__.py:F401
5+
exclude =
6+
.git
7+
__pycache__
8+
setup.py
9+
build
10+
dist
11+
.venv
12+
.tox
13+
.mypy_cache
14+
.pytest_cache
15+
.vscode
16+
.github

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
strategy:
2323
matrix:
24-
python-version: [2.7, 3.5, 3.6, 3.7]
24+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
2525

2626
steps:
2727
- uses: actions/checkout@v1
@@ -47,7 +47,7 @@ jobs:
4747
runs-on: macos-latest
4848
strategy:
4949
matrix:
50-
python-version: [2.7, 3.5, 3.6, 3.7]
50+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
5151

5252
steps:
5353
- uses: actions/checkout@v1
@@ -73,7 +73,7 @@ jobs:
7373
runs-on: windows-latest
7474
strategy:
7575
matrix:
76-
python-version: [2.7, 3.5, 3.6, 3.7]
76+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
7777

7878
steps:
7979
- uses: actions/checkout@v1

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: stable
4+
hooks:
5+
- id: black
6+
7+
- repo: https://gitlab.com/pycqa/flake8
8+
rev: 3.7.8
9+
hooks:
10+
- id: flake8
11+
12+
- repo: https://github.com/pre-commit/mirrors-isort
13+
rev: v4.3.21
14+
hooks:
15+
- id: isort
16+
additional_dependencies: [toml]
17+
exclude: ^.*/?setup\.py$
18+
19+
- repo: https://github.com/pre-commit/pre-commit-hooks
20+
rev: v2.3.0
21+
hooks:
22+
- id: trailing-whitespace
23+
- id: end-of-file-fixer
24+
- id: debug-statements

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typing = { version = "^3.6", python = "~2.7 || ~3.4" }
2323
pytest = "^4.1"
2424
pytest-cov = "^2.8.1"
2525
tox = "^3.12"
26+
pre-commit = "^1.10"
2627

2728
[tool.isort]
2829
line_length = 88

semver/patterns.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import re
22

3+
34
MODIFIERS = (
45
"[._-]?"
56
r"((?!post)(?:beta|b|c|pre|RC|alpha|a|patch|pl|p|dev)(?:(?:[.-]?\d+)*)?)?"

semver/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from typing import List
44
from typing import Optional
5+
from typing import Union
56

67
from .empty_constraint import EmptyConstraint
78
from .exceptions import ParseVersionError

semver/version_constraint.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
import semver
2+
3+
14
class VersionConstraint:
25
def is_empty(self): # type: () -> bool
36
raise NotImplementedError()
47

58
def is_any(self): # type: () -> bool
69
raise NotImplementedError()
710

8-
def allows(self, version): # type: (Version) -> bool
11+
def allows(self, version): # type: (semver.Version) -> bool
912
raise NotImplementedError()
1013

1114
def allows_all(self, other): # type: (VersionConstraint) -> bool

semver/version_range.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from typing import List
2+
3+
import semver
4+
15
from .empty_constraint import EmptyConstraint
26
from .version_constraint import VersionConstraint
37
from .version_union import VersionUnion
@@ -58,7 +62,7 @@ def is_empty(self):
5862
def is_any(self):
5963
return self._min is None and self._max is None
6064

61-
def allows(self, other): # type: (Version) -> bool
65+
def allows(self, other): # type: (semver.Version) -> bool
6266
if self._min is not None:
6367
if other < self._min:
6468
return False

semver/version_union.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from typing import List
2+
3+
import semver
4+
15
from .empty_constraint import EmptyConstraint
26
from .version_constraint import VersionConstraint
37

@@ -72,7 +76,7 @@ def is_empty(self):
7276
def is_any(self):
7377
return False
7478

75-
def allows(self, version): # type: (Version) -> bool
79+
def allows(self, version): # type: (semver.Version) -> bool
7680
return any([constraint.allows(version) for constraint in self._ranges])
7781

7882
def allows_all(self, other): # type: (VersionConstraint) -> bool
@@ -214,7 +218,7 @@ def our_next_range(include_current=True):
214218

215219
def _ranges_for(
216220
self, constraint
217-
): # type: (VersionConstraint) -> List[VersionRange]
221+
): # type: (VersionConstraint) -> List[semver.VersionRange]
218222
from .version_range import VersionRange
219223

220224
if constraint.is_empty():

tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import pytest
22

3-
from semver import parse_constraint
43
from semver import Version
54
from semver import VersionRange
65
from semver import VersionUnion
6+
from semver import parse_constraint
77

88

99
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)