Skip to content
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

Merged
merged 1 commit into from
Nov 8, 2023
Merged

feat: strict typing #168

merged 1 commit into from
Nov 8, 2023

Conversation

khvn26
Copy link
Member

@khvn26 khvn26 commented May 30, 2023

No description provided.

@github-actions
Copy link

github-actions bot commented May 30, 2023

File Coverage
All files 100%

Minimum allowed coverage is 100%

Generated by 🐒 cobertura-action against e1b63c4

@khvn26 khvn26 force-pushed the feat/mypy branch 4 times, most recently from d891f1e to b2fa987 Compare May 31, 2023 00:31
@khvn26 khvn26 mentioned this pull request Jun 23, 2023
@matthewelwell matthewelwell linked an issue Aug 11, 2023 that may be closed by this pull request
@khvn26 khvn26 force-pushed the feat/mypy branch 9 times, most recently from 4a9ebb8 to 179e079 Compare August 24, 2023 14:19
@khvn26 khvn26 marked this pull request as ready for review August 24, 2023 14:20
@khvn26 khvn26 requested review from a team and novakzaballa September 14, 2023 08:09
Copy link

@novakzaballa novakzaballa left a 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?

@khvn26 khvn26 force-pushed the feat/mypy branch 2 times, most recently from 832de2c to 4fa7ec3 Compare September 18, 2023 16:06
@khvn26 khvn26 force-pushed the feat/mypy branch 6 times, most recently from d7402a9 to 1a44ac9 Compare October 25, 2023 17:12
@khvn26 khvn26 force-pushed the feat/mypy branch 3 times, most recently from c261709 to 4733f50 Compare November 7, 2023 08:33
- 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
Copy link

@zachaysan zachaysan left a 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.

flag_engine/engine.py Show resolved Hide resolved
flag_engine/features/models.py Show resolved Hide resolved
flag_engine/utils/json/encoders.py Show resolved Hide resolved
@khvn26 khvn26 requested a review from zachaysan November 7, 2023 14:40
Copy link
Contributor

@matthewelwell matthewelwell left a 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],
Copy link
Contributor

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!

Copy link
Member Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why SupportsStr ?

Copy link
Member Author

@khvn26 khvn26 Nov 8, 2023

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:
Copy link
Contributor

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?

Copy link
Member Author

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.

@khvn26 khvn26 merged commit 7262b48 into main Nov 8, 2023
4 checks passed
@khvn26 khvn26 deleted the feat/mypy branch November 8, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pydantic V2 update
4 participants