-
Notifications
You must be signed in to change notification settings - Fork 44
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
Update type hints and organize import modules #315
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #315 +/- ##
==========================================
- Coverage 82.89% 82.87% -0.02%
==========================================
Files 41 41
Lines 4292 4287 -5
==========================================
- Hits 3558 3553 -5
Misses 734 734 ☔ View full report in Codecov by Sentry. |
Well, it seems that even after adding |
The Python 3.9 issue appears to be resolved by adding quotes to certain variables, as seen in |
By the way, I've noticed that there are some modules imported in each section of |
Thanks so much for this giant cleanup PR!
I think we can organize at top now. Originally, that file was split into many pieces, and we moved it into one as a refactor, but didn't get to cleaning up redundant imports 😓. Are you using a tool like isort or ruff's sorting to sort the imports? In any event, if you're happy with the PR as is, I'm happy to review / merge! (Can always figure out using isort/ruff sorting after merging) |
@machow I've re-organized the import modules at the top for Personally I've started using ruff to replace |
|
||
if TYPE_CHECKING: | ||
from great_tables._types import GTSelf | ||
|
||
|
||
RGBColor: TypeAlias = tuple[int, int, int] |
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 great
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 really great, thanks for bringing our annotations into the python 3.9+ world!
I left a note wondering there's a better name for X
in _format_vals.py
. But this module isn't heavily used, so it seems okay to punt!
|
||
if TYPE_CHECKING: | ||
from ._formats import DateStyle, TimeStyle | ||
from ._tbl_data import SeriesLike | ||
|
||
|
||
def _make_one_col_table(vals: Union[Any, List[Any], SeriesLike]) -> GT: | ||
X: TypeAlias = "Any | list[Any] | SeriesLike" |
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.
We might want to give this a more informative name? (Or maybe not?)
edit: seems okay as is for now
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.
@machow I hope you can bear with me as I couldn't find a more suitable name. I used X
because it appears that the first parameter of all val_*
functions is named x
.
@@ -702,8 +699,8 @@ class SpannerInfo: | |||
spanner_label: str | None = None | |||
spanner_units: str | None = None | |||
spanner_pattern: str | None = None | |||
vars: list[str] = field(default_factory=lambda: []) | |||
built: Optional[str] = None | |||
vars: list[str] = field(default_factory=list) |
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.
great catch 😅
Fix small pre-commit issues by 5c3fe2c. |
Sorry about the formatting issue in the merge commit, and thanks for all this helpful work! |
This PR, related to #312, is aimed at updating the type hints of our codebase using newer syntax. During this process, I believe it might be beneficial to organize the import modules using #119 isort.
I hope this PR will lay a solid foundation for us to adopt more advanced techniques of type hints in the future.