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

Codebase cleanup and minor improvements #305

Merged
merged 32 commits into from
Apr 22, 2024
Merged

Conversation

jrycw
Copy link
Contributor

@jrycw jrycw commented Apr 19, 2024

This PR primarily focuses on cleaning up our codebase, largely based on the discussion in #302. However, during my review of the code, I also identified several minor areas for improvement, which I've addressed in this PR.

These modifications may contain some subjective changes. I kindly ask the team to review them based on your judgment. Any feedback or comments would be greatly appreciated.

jrycw added 15 commits April 19, 2024 11:10
remove unused imports
remove unused imports
remove unused imports
fix unpacking
fix unpacking
fix isinstance
remove unused imports
fix isinstance
remove unused import
`location` should be `locations`
remove unused import
remove unused import
@codecov-commenter
Copy link

codecov-commenter commented Apr 19, 2024

Codecov Report

Attention: Patch coverage is 73.17073% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 81.88%. Comparing base (0f0c024) to head (3c13937).

Files Patch % Lines
great_tables/_options.py 37.50% 5 Missing ⚠️
great_tables/_utils.py 20.00% 4 Missing ⚠️
great_tables/_formats.py 83.33% 1 Missing ⚠️
great_tables/_styles.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #305      +/-   ##
==========================================
+ Coverage   81.66%   81.88%   +0.21%     
==========================================
  Files          41       41              
  Lines        4276     4256      -20     
==========================================
- Hits         3492     3485       -7     
+ Misses        784      771      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

fix the wrong logic of isinstance
revert isinstance style for `_assert_str_scalar` and `_assert_str_list`
simplify the logic of `_unique_set`
revert the logic of `_unique_set`
@@ -406,7 +404,7 @@ def _render_as_html(
return finalized_table

def _finalize_html_table(
style: str, quarto_disable_processing: str, quarto_use_bootstrap: str, *args: Any
self, style: str, quarto_disable_processing: str, quarto_use_bootstrap: str, *args: Any
Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @rich-iannone If this is unused, I think we can take it out (but can also punt that to a later PR :)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this is entirely unused. Let's remove it in this PR.

@@ -11,7 +11,7 @@

def get_row_reorder_df(groups: RowGroups, stub_df: Stub) -> list[TupleStartFinal]:
# Get the number of non-None entries in the `groupname_col`
n_stub_entries = len([entry for entry in stub_df if entry.group_id is not None])
n_stub_entries = sum(1 for entry in stub_df if entry.group_id is not None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a fan of len(), since it's a strong indicator that the length of something is being taken (whereas sum in combo with 1s is two elements that together do something similar).

(just my take; leaving to y'all :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@machow it's merely a coding preference. Please feel free to revert back to using len, as it might contribute to a more consistent codebase.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also in agreement with keeping this with len()

Copy link
Collaborator

@machow machow left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! I left a quick thought about using sum(1...), but am okay with it being used :).

@rich-iannone do you want to take a look (if useful) and merge?

Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

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

LGTM!

@rich-iannone
Copy link
Member

Thank you @jrycw for all the work done in this PR! Will be merging this now.

@rich-iannone rich-iannone merged commit b6a3c4c into posit-dev:main Apr 22, 2024
9 checks passed
@jrycw jrycw deleted the fix-302 branch April 22, 2024 13:59
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.

None yet

4 participants