Skip to content

Commit

Permalink
Fix flask8 version 6.1.0 validation errors (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhirupandey authored Aug 1, 2023
1 parent 66e9b3a commit c041ba4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ repos:
- id: check-added-large-files

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.0
rev: v1.4.1
hooks:
- id: mypy

Expand Down
8 changes: 4 additions & 4 deletions src/coherence/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def compose(self, before: ValueExtractor[T, E]) -> ValueExtractor[T, E]:
"""
if before is None:
raise ValueError("before cannot be null")
if type(before) == ValueExtractor:
if type(before) == ValueExtractor: # noqa: E721
return before.and_then(self)
else:
return ChainedExtractor([before, self])
Expand All @@ -53,7 +53,7 @@ def and_then(self, after: ValueExtractor[T, E]) -> ValueExtractor[T, E]:
"""
if after is None:
raise ValueError("after cannot be null")
if type(after) == ChainedExtractor:
if type(after) == ChainedExtractor: # noqa: E721
return ChainedExtractor([self, after])
else:
return after.compose(self)
Expand Down Expand Up @@ -129,7 +129,7 @@ def __init__(self, extractors_or_method: str | Sequence[ValueExtractor[T, Any]])
sequence of method names which results in a ChainedExtractor that is based on an array of corresponding
:class:`coherence.extractor.UniversalExtractor` objects
"""
if type(extractors_or_method) == str:
if type(extractors_or_method) == str: # noqa: E721
e = list()
names = extractors_or_method.split(".")
for name in names:
Expand All @@ -152,7 +152,7 @@ def __init__(self, extractors_or_method: str | Sequence[ValueExtractor[Any, Any]
sequence of method names which results in a ChainedExtractor that is based on an array of corresponding
:class:`coherence.extractor.UniversalExtractor` objects
"""
if type(extractors_or_method) == str:
if type(extractors_or_method) == str: # noqa: E721
e = list()
names = extractors_or_method.split(",")
for name in names:
Expand Down
2 changes: 1 addition & 1 deletion src/coherence/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, extractor: ExtractorExpression[T, E]):
super().__init__()
if isinstance(extractor, ValueExtractor):
self.extractor = extractor
elif type(extractor) == str:
elif isinstance(extractor, str):
self.extractor = Extractors.extract(extractor)
else:
raise ValueError("extractor cannot be any other type")
Expand Down
8 changes: 4 additions & 4 deletions src/coherence/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, value_extractor: ExtractorExpression[V, R]):
else:
if isinstance(value_extractor, ValueExtractor):
self.extractor = value_extractor
elif type(value_extractor) == str:
elif isinstance(value_extractor, str):
self.extractor = Extractors.extract(value_extractor)
else:
raise ValueError("value_extractor cannot be any other type")
Expand Down Expand Up @@ -233,7 +233,7 @@ def __init__(
:param post_multiplication: pass true to return the value as it was before it was multiplied, or pass false
to return the value as it is after it is multiplied
"""
if type(name_or_manipulator) == str:
if isinstance(name_or_manipulator, str):
manipulator: ValueManipulator[Any, Numeric] = self.create_custom_manipulator(name_or_manipulator)
super().__init__(manipulator)
else:
Expand Down Expand Up @@ -266,7 +266,7 @@ def __init__(self, name_or_manipulator: ManipulatorExpression, increment: Numeri
:param post_increment: pass `True` to return the value as it was before it was incremented, or pass `False`
to return the value as it is after it is incremented
"""
if type(name_or_manipulator) == str:
if isinstance(name_or_manipulator, str):
manipulator: ValueManipulator[Any, Numeric] = self.create_custom_manipulator(name_or_manipulator)
super().__init__(manipulator)
else:
Expand Down Expand Up @@ -477,7 +477,7 @@ def __init__(self, updater_or_property_name: UpdaterExpression[V, bool], value:
:param value: the value to update the target entry with
"""
super().__init__()
if type(updater_or_property_name) == str:
if type(updater_or_property_name) == str: # noqa: E721
self.updater: ValueUpdater[V, bool]
if updater_or_property_name.find(".") == -1:
self.updater = UniversalUpdater(updater_or_property_name)
Expand Down
2 changes: 1 addition & 1 deletion src/coherence/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def serialize(self, obj: object) -> bytes:
return b

def deserialize(self, value: bytes) -> T: # type: ignore
if type(value) == bytes:
if isinstance(value, bytes):
s = value.decode()
if value.__len__() == 0: # empty string
return cast(T, None)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def test_get_and_put(setup_and_teardown: NamedCache[str, str | int | Perso
v2: Person = Person.andy()
await cache.put(k2, v2)
r = await cache.get(k2)
assert type(r) == Person
assert isinstance(r, Person)
assert r.name == k2
assert r.address.city == Person.andy().address.city

Expand Down Expand Up @@ -460,7 +460,7 @@ async def test_invoke(setup_and_teardown: NamedCache[str, str | Person]) -> None
r4: str = await cache.invoke(k3, ExtractorProcessor(UniversalExtractor("name")))
assert r4 == k3
r5: Address = await cache.invoke(k3, ExtractorProcessor(UniversalExtractor("address")))
assert type(r5) == Address
assert isinstance(r5, Address)
assert r5.zipcode == v3.address.zipcode
r6: int = await cache.invoke(k3, ExtractorProcessor(ChainedExtractor("address.zipcode")))
assert r6 == v3.address.zipcode
Expand Down
2 changes: 1 addition & 1 deletion tests/test_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async def test_extractor(setup_and_teardown: NamedCache[Any, Any]) -> None:
r = await cache.invoke(k3, Processors.extract("name"))
assert r == k3
r = await cache.invoke(k3, Processors.extract("address"))
assert type(r) == Address
assert isinstance(r, Address)
assert r.zipcode == v3.address.zipcode
r = await cache.invoke(k3, Processors.extract("address.zipcode"))
assert r == v3.address.zipcode
Expand Down

0 comments on commit c041ba4

Please sign in to comment.