feat(python, rust): added new Config
formatting option set_tbl_column_data_type_inline
, fixed reading of env vars, improved interaction between formatting options
#5243
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Final piece (probably?) of
Config
overhaul/enhancement ;)Updates:
Fixed reading boolean environment vars from Rust (was previously just checking if a var was set using
is_ok()
, but was not actually checking its value, so you couldn't set to "0", you'd have to completely unset it - which doesn't play well with saving explicit config options, state, context-scope, etc). Now respects both "1" & "0" values for allConfig
boolean vars and handles them appropriately.Added a lot of before/after table formatting examples to the docstrings, showing the visual impact of the given option.
Fixed various format interactions - for example: if you dropped column types you don't want the
---
dtype separator to persist, so now automatically dropping that as well (inferring a few other similar cases - leads to more consistent/pleasant formatting when setting a few different options).Renamed
set_tbl_hide_column_separator
toset_tbl_hide_dtype_separator
, as the initial name is misleading (the separator being hidden has nothing to do with columns - it's the one between the name and the dtype). Technically breaking, but I suspect the number of affect people is going to be zero, or very very close to zero, so... ;)Removed
set_utf8_tables()
as this is never actually used - polars table format defaults to utf8; the only reason to change it to ascii is because you can't output utf8 strings (primitive tty/etc), in which case you are very unlikely to change it back.If for some reason you find you do want to do this, can just use
set_ascii_tables(False)
instead, which will revert formatting back to utf8; no need for a redundant method. The other useful ascii formats (such as markdown) are accessible through a different option anyway - for example:set_tbl_formatting("ASCII_MARKDOWN")
.Removed
set_tbl_change_column_data_type_position_format
; the name isn't clear and it's also redundant because you can get the same effect through the better-namedset_tbl_hide_dtype_separator
.New formatting option
set_tbl_column_data_type_inline(True)
, which inlines the dtype after the name; trades some horizontal space for some vertical space:Additional test coverage: validates the new formatting options, context-scoping, and the interaction of different formatting options applied at the same time.
Misc:
Config
doctest forset_tbl_cols
was leaking its environment env change into other tests; once I stopped that, theto_dummies
doctest started failing as it was implicitly relying on the higher (non-default) number of columns that got set there; fixed that by slightly modifying the example.