Skip to content

Commit

Permalink
fix flake8-comprehension errors (#411)
Browse files Browse the repository at this point in the history
Split out from #401 to make it easier to review. Only cosmetic changes
have been made and some linters errors are suppressed.
  • Loading branch information
skshetry committed Sep 14, 2023
1 parent 4784513 commit 375c3c5
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 108 deletions.
4 changes: 1 addition & 3 deletions gto/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,5 @@ class BaseManager(BaseModel):
class Config:
arbitrary_types_allowed = True

def update_state(
self, state: BaseRegistryState
) -> BaseRegistryState: # pylint: disable=no-self-use
def update_state(self, state: BaseRegistryState) -> BaseRegistryState:
raise NotImplementedError
6 changes: 3 additions & 3 deletions gto/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=no-self-use, no-self-argument, inconsistent-return-statements, invalid-name, import-outside-toplevel
# pylint: disable=no-self-argument, inconsistent-return-statements, invalid-name, import-outside-toplevel
import pathlib
from pathlib import Path
from typing import Any, Dict, List, Optional
Expand Down Expand Up @@ -57,14 +57,14 @@ def enrichments(self) -> Dict[str, EnrichmentReader]:
return res

@validator("TYPES")
def types_are_valid(cls, v):
def types_are_valid(cls, v): # pylint: disable=no-self-use
if v:
for name in v:
assert_name_is_valid(name)
return v

@validator("STAGES")
def stages_are_valid(cls, v):
def stages_are_valid(cls, v): # pylint: disable=no-self-use
if v:
for name in v:
assert_name_is_valid(name)
Expand Down
2 changes: 1 addition & 1 deletion gto/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def discover( # pylint: disable=no-self-use
}
return {}

def describe( # pylint: disable=no-self-use
def describe(
self, url_or_scm: Union[str, Git], obj: str, rev: Optional[str]
) -> Optional[GTOInfo]:
with RepoIndexManager.from_url(url_or_scm) as index:
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ ignore =
# https://pypi.org/project/flake8-string-format/
max_line_length = 79
max-complexity = 15
select = B,C,E,F,W,T4,B902,T,P
show_source = true
count = true

Expand All @@ -44,7 +43,7 @@ show_error_context = True
show_traceback = True
pretty = True
disable_error_code = misc
# plugins = pydantic.mypy
plugins = pydantic.mypy

# See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports.
ignore_missing_imports = True
Expand Down
22 changes: 11 additions & 11 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ def test_assign(tmp_dir: TmpDir, scm: Git, name: str):
assert len(assignments) == 1
check_obj(
assignments[0].dict_state(),
dict(
artifact=name,
version="v0.0.1",
stage=stage,
author=author,
author_email=author_email,
message=message,
commit_hexsha=scm.get_rev(),
is_active=True,
ref=event.ref,
),
{
"artifact": name,
"version": "v0.0.1",
"stage": stage,
"author": author,
"author_email": author_email,
"message": message,
"commit_hexsha": scm.get_rev(),
"is_active": True,
"ref": event.ref,
},
{"created_at", "assignments", "unassignments", "tag", "activated_at"},
)
event = gto.api.assign(
Expand Down
134 changes: 67 additions & 67 deletions tests/test_showcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,33 +71,33 @@ def test_api(tmp_dir: TmpDir, scm: Git, showcase: Tuple[str, str]):

check_obj(
nn_version.dict_state(),
dict(
artifact="nn",
version="v0.0.1",
author=author,
author_email=author_email,
commit_hexsha=first_commit,
discovered=False,
is_active=True,
ref="nn@v0.0.1",
),
{
"artifact": "nn",
"version": "v0.0.1",
"author": author,
"author_email": author_email,
"commit_hexsha": first_commit,
"discovered": False,
"is_active": True,
"ref": "nn@v0.0.1",
},
skip_keys=skip_keys_registration,
)
nn_vstages = nn_artifact.get_vstages()
assert len(nn_vstages) == 1
assert isinstance(nn_vstages["staging"][0], VStage)
check_obj(
nn_vstages["staging"][0].dict_state(),
dict(
artifact="nn",
version="v0.0.1",
stage="staging",
is_active=True,
ref="nn#staging#1",
author=author,
author_email=author_email,
commit_hexsha=first_commit,
),
{
"artifact": "nn",
"version": "v0.0.1",
"stage": "staging",
"is_active": True,
"ref": "nn#staging#1",
"author": author,
"author_email": author_email,
"commit_hexsha": first_commit,
},
skip_keys=skip_keys_assignment,
)

Expand All @@ -110,30 +110,30 @@ def test_api(tmp_dir: TmpDir, scm: Git, showcase: Tuple[str, str]):
rf_ver1, rf_ver2 = rf_artifact.versions
check_obj(
rf_ver1.dict_state(),
dict(
artifact="rf",
version="v1.2.3",
is_active=True,
ref="rf@v1.2.3",
author=author,
author_email=author_email,
commit_hexsha=first_commit,
discovered=False,
),
{
"artifact": "rf",
"version": "v1.2.3",
"is_active": True,
"ref": "rf@v1.2.3",
"author": author,
"author_email": author_email,
"commit_hexsha": first_commit,
"discovered": False,
},
skip_keys=skip_keys_registration,
)
check_obj(
rf_ver2.dict_state(),
dict(
artifact="rf",
version="v1.2.4",
is_active=True,
ref="rf@v1.2.4",
author=author,
author_email=author_email,
commit_hexsha=second_commit,
discovered=False,
),
{
"artifact": "rf",
"version": "v1.2.4",
"is_active": True,
"ref": "rf@v1.2.4",
"author": author,
"author_email": author_email,
"commit_hexsha": second_commit,
"discovered": False,
},
skip_keys=skip_keys_registration,
)

Expand All @@ -155,40 +155,40 @@ def test_api(tmp_dir: TmpDir, scm: Git, showcase: Tuple[str, str]):

check_obj(
rf_a1.dict_state(),
dict(
artifact="rf",
version="v1.2.3",
stage="production",
tag="rf#production#1",
author=author,
author_email=author_email,
commit_hexsha=first_commit,
),
{
"artifact": "rf",
"version": "v1.2.3",
"stage": "production",
"tag": "rf#production#1",
"author": author,
"author_email": author_email,
"commit_hexsha": first_commit,
},
skip_keys=skip_keys_assignment,
)
check_obj(
rf_a3.dict_state(),
dict(
artifact="rf",
version="v1.2.4",
stage="production",
tag="rf#production#3",
author=author,
author_email=author_email,
commit_hexsha=second_commit,
),
{
"artifact": "rf",
"version": "v1.2.4",
"stage": "production",
"tag": "rf#production#3",
"author": author,
"author_email": author_email,
"commit_hexsha": second_commit,
},
skip_keys=skip_keys_assignment,
)
check_obj(
rf_a2.dict_state(),
dict(
artifact="rf",
version="v1.2.4",
stage="staging",
tag="rf#staging#2",
author=author,
author_email=author_email,
commit_hexsha=second_commit,
),
{
"artifact": "rf",
"version": "v1.2.4",
"stage": "staging",
"tag": "rf#staging#2",
"author": author,
"author_email": author_email,
"commit_hexsha": second_commit,
},
skip_keys=skip_keys_assignment,
)
60 changes: 39 additions & 21 deletions tests/test_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,45 @@ def test_name_tag(scm: Git):


def test_parse_name():
assert parse_name("path@v1.2.3") == dict(
name="path", version="v1.2.3", action=Action.REGISTER
)
assert parse_name("path@v1.2.3#5") == dict(
name="path", version="v1.2.3", action=Action.REGISTER, counter=5
)
assert parse_name("path@v1.2.3!") == dict(
name="path", version="v1.2.3", action=Action.DEREGISTER
)
assert parse_name("path@v1.2.3!#2") == dict(
name="path", version="v1.2.3", action=Action.DEREGISTER, counter=2
)
assert parse_name("path#stage") == dict(
name="path", action=Action.ASSIGN, stage="stage"
)
assert parse_name("path#stage#1") == dict(
name="path", action=Action.ASSIGN, stage="stage", counter=1
)
assert parse_name("path#stage!#2") == dict(
name="path", action=Action.UNASSIGN, stage="stage", counter=2
)
assert parse_name("path@v1.2.3") == {
"name": "path",
"version": "v1.2.3",
"action": Action.REGISTER,
}
assert parse_name("path@v1.2.3#5") == {
"name": "path",
"version": "v1.2.3",
"action": Action.REGISTER,
"counter": 5,
}
assert parse_name("path@v1.2.3!") == {
"name": "path",
"version": "v1.2.3",
"action": Action.DEREGISTER,
}
assert parse_name("path@v1.2.3!#2") == {
"name": "path",
"version": "v1.2.3",
"action": Action.DEREGISTER,
"counter": 2,
}
assert parse_name("path#stage") == {
"name": "path",
"action": Action.ASSIGN,
"stage": "stage",
}
assert parse_name("path#stage#1") == {
"name": "path",
"action": Action.ASSIGN,
"stage": "stage",
"counter": 1,
}
assert parse_name("path#stage!#2") == {
"name": "path",
"action": Action.UNASSIGN,
"stage": "stage",
"counter": 2,
}


@pytest.mark.parametrize(
Expand Down

0 comments on commit 375c3c5

Please sign in to comment.