-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: strict typing #168
feat: strict typing #168
Conversation
Minimum allowed coverage is Generated by 🐒 cobertura-action against e1b63c4 |
d891f1e
to
b2fa987
Compare
4a9ebb8
to
179e079
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khvn26 I am approving since in general it LGTM, however, there are a lot of changes, not sure if everything is OK, maybe we need another couple of eyes here?
832de2c
to
4fa7ec3
Compare
d7402a9
to
1a44ac9
Compare
c261709
to
4733f50
Compare
- add strict mode mypy, fix typing errors - add absolufy-imports, ditch relative imports - move segment evaluation logic to `flag_engine.segments.evaluation` module - add `type: ignore` comment for decorator usage on a property - add `type: ignore` comments for untyped dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I have a couple small questions, but no showstoppers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor comments / questions but looks good on the whole.
@@ -176,7 +176,7 @@ def _trait_value_typed( | |||
@wraps(func) | |||
def inner( | |||
segment_value: typing.Optional[str], | |||
trait_value: TraitValue, | |||
trait_value: typing.Union[TraitValue, semver.Version], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. More trait value pain!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is actually a typing pain to accommodate for L183-L185. Maybe we should actually move semver parsing inside the get_casting_function
.
|
||
def get_hashed_percentage_for_object_ids( | ||
object_ids: typing.Iterable[typing.Any], iterations: int = 1 | ||
object_ids: typing.Iterable[SupportsStr], iterations: int = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why SupportsStr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the broadest correct type I could think of without resorting to either Any
or a type: ignore
comment.
The "real" type is list[ int | str | UUID ]
, but that should not matter to the context of this function.
|
||
|
||
def remove_semver_suffix(value: str) -> str: | ||
def remove_semver_suffix(value: semver.Version) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true? I thought we did pass a string in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out we never did. All string values suffixed with ":semver"
are converted to semver.Version
before this function gets called.
No description provided.