Skip to content

Commit

Permalink
Fix pre-commit (#168)
Browse files Browse the repository at this point in the history
* update pre-commit

* pin pylint version

* Update setup.py

* fix flake8 warnings
  • Loading branch information
aguschin authored Jun 2, 2022
1 parent be2872a commit dd04a38
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 18 deletions.
13 changes: 12 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ repos:
- id: mixed-line-ending
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: 'https://github.com/pycqa/flake8'
rev: 4.0.1
hooks:
- id: flake8
args:
- '-j8'
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-debugger
- flake8-string-format
- repo: 'https://github.com/psf/black'
rev: 22.3.0
hooks:
Expand All @@ -41,6 +52,6 @@ repos:
hooks:
- id: pylint
name: pylint
entry: pylint
entry: pylint -v
language: system
types: [ python ]
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ disable=print-statement,
redefined-builtin, # TODO
wrong-import-order, # handeled by isort,
cannot-enumerate-pytest-fixtures, # TODO
invalid-name,
invalid-name

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
2 changes: 1 addition & 1 deletion gto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from gto.index import RepoIndexManager
from gto.registry import GitRegistry

__all__ = ["api", "CONFIG", "RepoIndexManager", "GitRegistry"]
__all__ = ["api", "CONFIG", "RepoIndexManager", "GitRegistry", "__version__"]
16 changes: 8 additions & 8 deletions gto/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,18 +360,18 @@ def format_hexsha(hexsha):

promotion = [
OrderedDict(
timestamp=l.created_at,
timestamp=p.created_at,
artifact=o.name,
event="promotion",
version=format_hexsha(l.version),
stage=l.stage,
commit=format_hexsha(l.commit_hexsha),
author=l.author,
author_email=l.author_email,
message=l.message,
version=format_hexsha(p.version),
stage=p.stage,
commit=format_hexsha(p.commit_hexsha),
author=p.author,
author_email=p.author_email,
message=p.message,
)
for o in artifacts.values()
for l in o.stages
for p in o.stages
]

events_order = {
Expand Down
10 changes: 6 additions & 4 deletions gto/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,17 @@ class BaseArtifact(BaseModel):

@property
def stages(self):
return [l for v in self.versions for l in v.promotions]
return [
promotion for version in self.versions for promotion in version.promotions
]

@property
def unique_stages(self):
return {l.stage for l in self.stages}
return {promotion.stage for promotion in self.stages}

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

def get_versions(
Expand Down Expand Up @@ -273,7 +275,7 @@ def find_artifact(self, name: str, create_new=False):

@property
def unique_stages(self):
return sorted({l for o in self.artifacts.values() for l in o.unique_stages})
return sorted({p for o in self.artifacts.values() for p in o.unique_stages})

def find_commit(self, name, version):
return (
Expand Down
2 changes: 1 addition & 1 deletion gto/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def is_valid(cls, version):
try:
cls.parse(version)
return True
except (InvalidVersion, ValueError, IndexError) as _:
except (InvalidVersion, ValueError, IndexError) as _: # noqa: F841
return False

@classmethod
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ignore =
B008, # Do not perform function calls in argument defaults: conflicts with typer
P1, # unindexed parameters in the str.format, see:
B902, # Invalid first argument 'cls' used for instance method.
C408, # Unnecessary call of 'dict()' literal
# https://pypi.org/project/flake8-string-format/
max_line_length = 79
max-complexity = 15
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"pytest-cov",
"pytest-lazy-fixture==0.6.3",
"pytest-mock",
"pylint",
"pylint<2.14",
# we use this to suppress pytest-related false positives in our tests.
"pylint-pytest",
# we use this to suppress some messages in tests, eg: foo/bar naming,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_showcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_api(showcase):
)

assert len(rf_artifact.stages) == 4
assert all(isinstance(l, BasePromotion) for l in rf_artifact.stages)
assert all(isinstance(p, BasePromotion) for p in rf_artifact.stages)
rf_l1, _ = rf_ver1.promotions
rf_l3, rf_l4 = rf_ver2.promotions

Expand Down

0 comments on commit dd04a38

Please sign in to comment.