jazzband / tablib

Python Module for Tabular Datasets in XLS, CSV, JSON, YAML, &c.
https://tablib.readthedocs.io/
MIT License
4.58k stars 589 forks source link

xlsx export: remove redundant code #541

Closed matthewhegarty closed 1 year ago

matthewhegarty commented 1 year ago

This PR removes what I believe is a redundant check from XLSX export dset_sheet(). It provides a minor simplification of the code.

If we check the source for openpyxl.cell.cell.Cell, the cell value setter calls _bind_value(). This method can raise a ValueError but not a TypeError. Therefore I have removed the checks for TypeError, and I assume that if this does occur somehow, then we would want this raised and not caught because this might be masking an error the user might be interested in.

I also removed catching TypeError when str(col) is called for the same reason.

I have added tests to increase the coverage.

codecov[bot] commented 1 year ago

Codecov Report

Merging #541 (61ae056) into master (bff435d) will increase coverage by 0.11%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #541      +/-   ##
==========================================
+ Coverage   91.28%   91.39%   +0.11%     
==========================================
  Files          28       28              
  Lines        2719     2720       +1     
==========================================
+ Hits         2482     2486       +4     
+ Misses        237      234       -3     
Impacted Files Coverage Δ
src/tablib/formats/_xlsx.py 100.00% <100.00%> (+2.97%) :arrow_up:
tests/test_tablib.py 98.73% <100.00%> (+<0.01%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more