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: support column_width in xlsx format #516

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Birdi7
Copy link

@Birdi7 Birdi7 commented Feb 17, 2022

This PR allows user to specify column width in XLXS format. For it has a default value, which is not suitable for long values in dataset. As a result, it is not convenient to look these tables. Also, it eliminates questions like #318 in future

I didn't find tests for exporting, so omitted this. Let me know if they are required

@codecov
Copy link

codecov bot commented Feb 17, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.11%. Comparing base (de1a47a) to head (0f7e2ef).
Report is 59 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #516      +/-   ##
==========================================
+ Coverage   90.84%   91.11%   +0.27%     
==========================================
  Files          28       28              
  Lines        2664     2702      +38     
==========================================
+ Hits         2420     2462      +42     
+ Misses        244      240       -4     

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

@Birdi7 Birdi7 changed the title feat: support column_width in xlxs format feat: support column_width in xlsx format Mar 31, 2022
@Birdi7
Copy link
Author

Birdi7 commented Mar 31, 2022

Hello @hugovk! Sorry for ping, but I just want to ask if you have any time for review and merge this?

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Thanks for the ping! Please could you add some tests that use the different possible values?

docs/formats.rst Outdated Show resolved Hide resolved
Co-authored-by: Hugo van Kemenade <[email protected]>
@Birdi7
Copy link
Author

Birdi7 commented Apr 1, 2022

@hugovk Thank you for the review! I've added the test on check the new feature, checkout test_xlsx_column_width. Would you mind review the PR, and if everything is ok merge it to master?

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Some general comments. And please could we have three separate test cases that call export_set with different values for column_width: None, an integer and "adaptive".

That way we see each branch of your code is running without error, and it will be reflected in the coverage.

AUTHORS Outdated Show resolved Hide resolved
docs/formats.rst Outdated Show resolved Hide resolved
docs/formats.rst Outdated Show resolved Hide resolved
src/tablib/formats/_xlsx.py Outdated Show resolved Hide resolved
src/tablib/formats/_xlsx.py Outdated Show resolved Hide resolved
@Birdi7
Copy link
Author

Birdi7 commented Apr 1, 2022

Thank you for such usefull comment! I've found a bug with new tests. Your comments are pushed, alongside with all three tests. What do you think on it?

tests/test_tablib.py Outdated Show resolved Hide resolved
@Birdi7
Copy link
Author

Birdi7 commented Jun 8, 2022

Thank you for your comment! I believe this significantly improves redability. Could please take a look if the PR is fine now?

src/tablib/formats/_xlsx.py Outdated Show resolved Hide resolved
Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Thank you! A couple of minor suggestions.




.. versionchanged:: 3.3.0
Copy link
Member

Choose a reason for hiding this comment

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

3.3.0 has been released, let's target 3.4.0:

Suggested change
.. versionchanged:: 3.3.0
.. versionchanged:: 3.4.0

Comment on lines +61 to +62
raise ValueError(f"Unsupported value `{column_width}` passed to `column_width` "
"parameter. It supports 'adaptive' or integer values")
Copy link
Member

Choose a reason for hiding this comment

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

Maybe something like this, to be closer to existing exceptions?

And let's start assigning exception messages to a variable first, for the reasons set out at https://github.com/henryiii/flake8-errmsg

Suggested change
raise ValueError(f"Unsupported value `{column_width}` passed to `column_width` "
"parameter. It supports 'adaptive' or integer values")
msg = (
f"Invalid value for column_width: {column_width}. "
f"Must be 'adaptive' or an integer."
)
raise ValueError(msg)

@rakinson
Copy link

Hi there, I would find this enhancement useful. Do you mind to take this last step to add this feature?
Thank you!

@Birdi7
Copy link
Author

Birdi7 commented Oct 8, 2024

Hi! I won't be able to finish this PR, so feel free to do that!

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.

3 participants