Skip to content

Commit dd04a38

Browse files
authored
Fix pre-commit (iterative#168)
* update pre-commit * pin pylint version * Update setup.py * fix flake8 warnings
1 parent be2872a commit dd04a38

File tree

9 files changed

+32
-18
lines changed

9 files changed

+32
-18
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ repos:
1717
- id: mixed-line-ending
1818
- id: sort-simple-yaml
1919
- id: trailing-whitespace
20+
- repo: 'https://github.com/pycqa/flake8'
21+
rev: 4.0.1
22+
hooks:
23+
- id: flake8
24+
args:
25+
- '-j8'
26+
additional_dependencies:
27+
- flake8-bugbear
28+
- flake8-comprehensions
29+
- flake8-debugger
30+
- flake8-string-format
2031
- repo: 'https://github.com/psf/black'
2132
rev: 22.3.0
2233
hooks:
@@ -41,6 +52,6 @@ repos:
4152
hooks:
4253
- id: pylint
4354
name: pylint
44-
entry: pylint
55+
entry: pylint -v
4556
language: system
4657
types: [ python ]

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ disable=print-statement,
165165
redefined-builtin, # TODO
166166
wrong-import-order, # handeled by isort,
167167
cannot-enumerate-pytest-fixtures, # TODO
168-
invalid-name,
168+
invalid-name
169169

170170
# Enable the message, report, category or checker with the given id(s). You can
171171
# either give multiple identifier separated by comma (,) or put this option

gto/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
from gto.index import RepoIndexManager
66
from gto.registry import GitRegistry
77

8-
__all__ = ["api", "CONFIG", "RepoIndexManager", "GitRegistry"]
8+
__all__ = ["api", "CONFIG", "RepoIndexManager", "GitRegistry", "__version__"]

gto/api.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,18 +360,18 @@ def format_hexsha(hexsha):
360360

361361
promotion = [
362362
OrderedDict(
363-
timestamp=l.created_at,
363+
timestamp=p.created_at,
364364
artifact=o.name,
365365
event="promotion",
366-
version=format_hexsha(l.version),
367-
stage=l.stage,
368-
commit=format_hexsha(l.commit_hexsha),
369-
author=l.author,
370-
author_email=l.author_email,
371-
message=l.message,
366+
version=format_hexsha(p.version),
367+
stage=p.stage,
368+
commit=format_hexsha(p.commit_hexsha),
369+
author=p.author,
370+
author_email=p.author_email,
371+
message=p.message,
372372
)
373373
for o in artifacts.values()
374-
for l in o.stages
374+
for p in o.stages
375375
]
376376

377377
events_order = {

gto/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,17 @@ class BaseArtifact(BaseModel):
102102

103103
@property
104104
def stages(self):
105-
return [l for v in self.versions for l in v.promotions]
105+
return [
106+
promotion for version in self.versions for promotion in version.promotions
107+
]
106108

107109
@property
108110
def unique_stages(self):
109-
return {l.stage for l in self.stages}
111+
return {promotion.stage for promotion in self.stages}
110112

111113
def __repr__(self) -> str:
112114
versions = ", ".join(f"'{v.name}'" for v in self.versions)
113-
stages = ", ".join(f"'{l}'" for l in self.unique_stages)
115+
stages = ", ".join(f"'{p}'" for p in self.unique_stages)
114116
return f"Artifact(versions=[{versions}], stages=[{stages}])"
115117

116118
def get_versions(
@@ -273,7 +275,7 @@ def find_artifact(self, name: str, create_new=False):
273275

274276
@property
275277
def unique_stages(self):
276-
return sorted({l for o in self.artifacts.values() for l in o.unique_stages})
278+
return sorted({p for o in self.artifacts.values() for p in o.unique_stages})
277279

278280
def find_commit(self, name, version):
279281
return (

gto/versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def is_valid(cls, version):
3939
try:
4040
cls.parse(version)
4141
return True
42-
except (InvalidVersion, ValueError, IndexError) as _:
42+
except (InvalidVersion, ValueError, IndexError) as _: # noqa: F841
4343
return False
4444

4545
@classmethod

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ignore =
77
B008, # Do not perform function calls in argument defaults: conflicts with typer
88
P1, # unindexed parameters in the str.format, see:
99
B902, # Invalid first argument 'cls' used for instance method.
10+
C408, # Unnecessary call of 'dict()' literal
1011
# https://pypi.org/project/flake8-string-format/
1112
max_line_length = 79
1213
max-complexity = 15

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"pytest-cov",
2020
"pytest-lazy-fixture==0.6.3",
2121
"pytest-mock",
22-
"pylint",
22+
"pylint<2.14",
2323
# we use this to suppress pytest-related false positives in our tests.
2424
"pylint-pytest",
2525
# we use this to suppress some messages in tests, eg: foo/bar naming,

tests/test_showcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_api(showcase):
101101
)
102102

103103
assert len(rf_artifact.stages) == 4
104-
assert all(isinstance(l, BasePromotion) for l in rf_artifact.stages)
104+
assert all(isinstance(p, BasePromotion) for p in rf_artifact.stages)
105105
rf_l1, _ = rf_ver1.promotions
106106
rf_l3, rf_l4 = rf_ver2.promotions
107107

0 commit comments

Comments
 (0)