flexablelib 2.2.4__tar.gz → 2.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. {flexablelib-2.2.4 → flexablelib-2.3.0}/CHANGELOG.md +22 -0
  2. {flexablelib-2.2.4/flexablelib.egg-info → flexablelib-2.3.0}/PKG-INFO +23 -1
  3. {flexablelib-2.2.4 → flexablelib-2.3.0}/README.md +22 -0
  4. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/columns.py +3 -0
  5. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/table.py +14 -14
  6. {flexablelib-2.2.4 → flexablelib-2.3.0/flexablelib.egg-info}/PKG-INFO +23 -1
  7. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib.egg-info/SOURCES.txt +1 -0
  8. {flexablelib-2.2.4 → flexablelib-2.3.0}/package.json +1 -1
  9. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_stress_matrix.py +7 -0
  10. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v219_fixes.py +3 -2
  11. flexablelib-2.3.0/tests/test_v230_none.py +88 -0
  12. {flexablelib-2.2.4 → flexablelib-2.3.0}/tools/stress_matrix.py +57 -2
  13. {flexablelib-2.2.4 → flexablelib-2.3.0}/LICENSE +0 -0
  14. {flexablelib-2.2.4 → flexablelib-2.3.0}/MANIFEST.in +0 -0
  15. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/__init__.py +0 -0
  16. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/_speedups.c +0 -0
  17. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/_width_tables.h +0 -0
  18. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/cells.py +0 -0
  19. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/colors.py +0 -0
  20. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/fast.py +0 -0
  21. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/merges.py +0 -0
  22. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/options.py +0 -0
  23. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/py.typed +0 -0
  24. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/readers.py +0 -0
  25. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/style_compositions.py +0 -0
  26. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/table_strings.py +0 -0
  27. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/text_width.py +0 -0
  28. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/utils.py +0 -0
  29. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib/writers.py +0 -0
  30. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib.egg-info/dependency_links.txt +0 -0
  31. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib.egg-info/requires.txt +0 -0
  32. {flexablelib-2.2.4 → flexablelib-2.3.0}/flexablelib.egg-info/top_level.txt +0 -0
  33. {flexablelib-2.2.4 → flexablelib-2.3.0}/pytest.ini +0 -0
  34. {flexablelib-2.2.4 → flexablelib-2.3.0}/setup.cfg +0 -0
  35. {flexablelib-2.2.4 → flexablelib-2.3.0}/setup.py +0 -0
  36. {flexablelib-2.2.4 → flexablelib-2.3.0}/style_examples.md +0 -0
  37. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/conftest.py +0 -0
  38. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/helpers.py +0 -0
  39. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_cells.py +0 -0
  40. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_columns.py +0 -0
  41. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_excel.py +0 -0
  42. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_features.py +0 -0
  43. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_issues.py +0 -0
  44. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_merge_edge_matrix.py +0 -0
  45. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_merges.py +0 -0
  46. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_readme_examples.py +0 -0
  47. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_style_line_widths.py +0 -0
  48. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_styles.py +0 -0
  49. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_text_width.py +0 -0
  50. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_two_pass_measurement.py +0 -0
  51. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_upstream_issues.py +0 -0
  52. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v2021_fixes.py +0 -0
  53. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v210_rows_copy.py +0 -0
  54. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v2110_fixes.py +0 -0
  55. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v211_fixes.py +0 -0
  56. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v213_features.py +0 -0
  57. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v214_features.py +0 -0
  58. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v215_features.py +0 -0
  59. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v216_features.py +0 -0
  60. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v217_features.py +0 -0
  61. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v218_features.py +0 -0
  62. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v219_coverage.py +0 -0
  63. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v220_exports.py +0 -0
  64. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v221_fixes.py +0 -0
  65. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v222_fixes.py +0 -0
  66. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v223_fixes.py +0 -0
  67. {flexablelib-2.2.4 → flexablelib-2.3.0}/tests/test_v224_fixes.py +0 -0
  68. {flexablelib-2.2.4 → flexablelib-2.3.0}/tools/benchmark.py +0 -0
  69. {flexablelib-2.2.4 → flexablelib-2.3.0}/tools/generate_width_tables.py +0 -0
  70. {flexablelib-2.2.4 → flexablelib-2.3.0}/tools/readme_gallery.py +0 -0
  71. {flexablelib-2.2.4 → flexablelib-2.3.0}/tools/text_to_png.py +0 -0
@@ -2,6 +2,28 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [2.3.0] - 2026-11-07
6
+
7
+ ### Changed (visible behaviour)
8
+ - Explicit ``None`` now displays ``missing_value`` (blank by default), just
9
+ like a padding gap or ``table.missing``. Previously it printed ``None``.
10
+ Use the string ``"None"`` to retain that literal output. Applies to every
11
+ style, printing/``compose``, pagination, streaming and transposition.
12
+ - A numeric column containing ``None`` keeps its numeric type, alignment
13
+ and decimal axis; wrapping no longer splits its numbers as text.
14
+ - Derived tables used for pagination/streaming preserve gaps as missing data
15
+ instead of converting the placeholder to text before inferring types.
16
+ ``Table(rows=t.rows)`` preserves the visible cells with matching settings.
17
+ Raw rows and export missing-value semantics are unchanged.
18
+
19
+ ### Tests and documentation
20
+ - Regressions across all 56 styles, three missing-value displays and all
21
+ render paths; raw/formatted exports, row round-trips and numeric wrapping.
22
+ - The stress matrix now compares None, padding sentinels and row round-trips
23
+ in every style/theme and mode; stream budgets include decimal-axis width
24
+ and a feasible terminal budget (narrow fits are covered outside stream).
25
+ - README and ``docs/MISSING_VALUES.md`` explain the visible change.
26
+
5
27
  ## [2.2.4] - 2026-11-07
6
28
 
7
29
  Found by a new stress matrix (``tools/stress_matrix.py``): every style and
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib
3
- Version: 2.2.4
3
+ Version: 2.3.0
4
4
  Summary: Fast, dependency-free terminal tables for Python: 56 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Author: Benjamin Ramirez
@@ -347,6 +347,28 @@ print(new_table)
347
347
  ```
348
348
  The missing value aligns as if it was of the same type of the other data in the column.
349
349
 
350
+ **Changed in 2.3.0:** an explicit `None` is a missing cell, just like a
351
+ padding gap or `table.missing`. It displays `missing_value` (blank by default),
352
+ not the text `"None"`. Set `table.missing_value = '?'` to show gaps explicitly.
353
+ Use the string `"None"` if you want that literal text. This applies to printing,
354
+ `compose()`, pagination, streaming, and transposition in every style.
355
+
356
+ Missing cells do not turn numeric columns into text: numeric alignment and
357
+ the decimal axis are preserved, and `overflow='wrap'` does not split floats
358
+ because a column contains `None`. Raw `rows` and exports still represent gaps
359
+ as `None`; rendering `Table(rows=table.rows)` reproduces the same cells (copy
360
+ headers and display settings too if you changed them).
361
+
362
+ ```python
363
+ table = Table(rows=[[924.87], [None], [1.25]])
364
+ assert 'None' not in table.compose()
365
+ assert Table(rows=table.rows).compose() == table.compose()
366
+ table.missing_value = '?' # changes the display, not stored None values
367
+ ```
368
+
369
+ See [missing-cell semantics](docs/MISSING_VALUES.md) for migration details.
370
+
371
+
350
372
  This shows how to get the row and column count. If the index is shown, this count remains unaffected by that column, although, you can get the internal count.
351
373
 
352
374
  ### Code Example
@@ -282,6 +282,28 @@ print(new_table)
282
282
  ```
283
283
  The missing value aligns as if it was of the same type of the other data in the column.
284
284
 
285
+ **Changed in 2.3.0:** an explicit `None` is a missing cell, just like a
286
+ padding gap or `table.missing`. It displays `missing_value` (blank by default),
287
+ not the text `"None"`. Set `table.missing_value = '?'` to show gaps explicitly.
288
+ Use the string `"None"` if you want that literal text. This applies to printing,
289
+ `compose()`, pagination, streaming, and transposition in every style.
290
+
291
+ Missing cells do not turn numeric columns into text: numeric alignment and
292
+ the decimal axis are preserved, and `overflow='wrap'` does not split floats
293
+ because a column contains `None`. Raw `rows` and exports still represent gaps
294
+ as `None`; rendering `Table(rows=table.rows)` reproduces the same cells (copy
295
+ headers and display settings too if you changed them).
296
+
297
+ ```python
298
+ table = Table(rows=[[924.87], [None], [1.25]])
299
+ assert 'None' not in table.compose()
300
+ assert Table(rows=table.rows).compose() == table.compose()
301
+ table.missing_value = '?' # changes the display, not stored None values
302
+ ```
303
+
304
+ See [missing-cell semantics](docs/MISSING_VALUES.md) for migration details.
305
+
306
+
285
307
  This shows how to get the row and column count. If the index is shown, this count remains unaffected by that column, although, you can get the internal count.
286
308
 
287
309
  ### Code Example
@@ -628,6 +628,9 @@ def _typify_column(column: Union[list, tuple],
628
628
  if index_column:
629
629
  # If it is the index column, it will be took in count as int.
630
630
  identified_types.append(int.__name__)
631
+ elif row is None:
632
+ # An explicit None is the same gap as the padding sentinel.
633
+ identified_types.append(TYPE_NAMES.value_placer_)
631
634
  elif row != '':
632
635
  # Get the type as long as is not an empty string.
633
636
  identified_types.append(type(row).__name__)
@@ -1244,7 +1244,11 @@ class Table(object):
1244
1244
  @property
1245
1245
  def missing_value(self) -> Any:
1246
1246
  """
1247
- A placeholder for empty cells.
1247
+ A placeholder for missing cells, including explicit None (since 2.3).
1248
+
1249
+ None does not turn a numeric column into text. Use the string
1250
+ 'None' to display that literal word. Raw rows and exports keep
1251
+ missing cells as None, independently of this display placeholder.
1248
1252
 
1249
1253
  Default is::
1250
1254
 
@@ -2684,8 +2688,8 @@ class Table(object):
2684
2688
 
2685
2689
  A cell holding this renders as ``missing_value`` and does not affect
2686
2690
  the column's inferred type, so a numeric column with gaps stays
2687
- numeric and stays right-aligned. Assigning None or '' instead would
2688
- make the column textual.
2691
+ numeric and stays right-aligned. None does the same; an empty string
2692
+ would make the column textual.
2689
2693
 
2690
2694
  Used by the readers to represent NaN and NULL, and available for
2691
2695
  building tables with gaps by hand::
@@ -4592,20 +4596,16 @@ class Table(object):
4592
4596
  # For adding the missing value where the ValuePlacer
4593
4597
  # is used (in the rows with index).
4594
4598
  for column_i, column in enumerate(row):
4595
- if isinstance(column, ValuePlacer):
4596
- rows_with_i[row_i][column_i] = column(
4597
- self.__missing_value
4598
- )
4599
+ if column is None or isinstance(column, ValuePlacer):
4600
+ rows_with_i[row_i][column_i] = self.__missing_value
4599
4601
 
4600
4602
  # For adding the missing value where the ValuePlacer
4601
4603
  # is used.
4602
4604
  rows = [list(row) for row in self.__rows]
4603
4605
  for row_i, row in enumerate(rows):
4604
4606
  for column_i, column in enumerate(row):
4605
- if isinstance(column, ValuePlacer):
4606
- rows[row_i][column_i] = column(
4607
- self.__missing_value
4608
- )
4607
+ if column is None or isinstance(column, ValuePlacer):
4608
+ rows[row_i][column_i] = self.__missing_value
4609
4609
 
4610
4610
  # Filter and sort the display copies together so the index column
4611
4611
  # stays aligned with its row.
@@ -6283,13 +6283,13 @@ class Table(object):
6283
6283
  out.__border_texts = [dict(entry) for entry in self.__border_texts]
6284
6284
 
6285
6285
  def __stored_row(self, row_i, headers):
6286
- """One stored row with gaps turned into the missing value."""
6286
+ """One stored row with gaps kept as None for derived-table typing."""
6287
6287
  row = []
6288
6288
  for header in headers:
6289
6289
  col = self.__columns.get(header, [])
6290
- cell = col[row_i] if row_i < len(col) else self.__missing_value
6290
+ cell = col[row_i] if row_i < len(col) else None
6291
6291
  if isinstance(cell, ValuePlacer):
6292
- cell = self.__missing_value
6292
+ cell = None
6293
6293
  row.append(cell)
6294
6294
  return row
6295
6295
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib
3
- Version: 2.2.4
3
+ Version: 2.3.0
4
4
  Summary: Fast, dependency-free terminal tables for Python: 56 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Author: Benjamin Ramirez
@@ -347,6 +347,28 @@ print(new_table)
347
347
  ```
348
348
  The missing value aligns as if it was of the same type of the other data in the column.
349
349
 
350
+ **Changed in 2.3.0:** an explicit `None` is a missing cell, just like a
351
+ padding gap or `table.missing`. It displays `missing_value` (blank by default),
352
+ not the text `"None"`. Set `table.missing_value = '?'` to show gaps explicitly.
353
+ Use the string `"None"` if you want that literal text. This applies to printing,
354
+ `compose()`, pagination, streaming, and transposition in every style.
355
+
356
+ Missing cells do not turn numeric columns into text: numeric alignment and
357
+ the decimal axis are preserved, and `overflow='wrap'` does not split floats
358
+ because a column contains `None`. Raw `rows` and exports still represent gaps
359
+ as `None`; rendering `Table(rows=table.rows)` reproduces the same cells (copy
360
+ headers and display settings too if you changed them).
361
+
362
+ ```python
363
+ table = Table(rows=[[924.87], [None], [1.25]])
364
+ assert 'None' not in table.compose()
365
+ assert Table(rows=table.rows).compose() == table.compose()
366
+ table.missing_value = '?' # changes the display, not stored None values
367
+ ```
368
+
369
+ See [missing-cell semantics](docs/MISSING_VALUES.md) for migration details.
370
+
371
+
350
372
  This shows how to get the row and column count. If the index is shown, this count remains unaffected by that column, although, you can get the internal count.
351
373
 
352
374
  ### Code Example
@@ -62,6 +62,7 @@ tests/test_v221_fixes.py
62
62
  tests/test_v222_fixes.py
63
63
  tests/test_v223_fixes.py
64
64
  tests/test_v224_fixes.py
65
+ tests/test_v230_none.py
65
66
  tools/benchmark.py
66
67
  tools/generate_width_tables.py
67
68
  tools/readme_gallery.py
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flexablelib",
3
- "version": "2.2.4",
3
+ "version": "2.3.0",
4
4
  "private": true,
5
5
  "description": "Flexible console and HTML tables for Python: styles, merges, colors, widths, decimal alignment.",
6
6
  "repository": {
@@ -45,3 +45,10 @@ def test_render_invariants(case):
45
45
  @pytest.mark.parametrize('combo', range(len(matrix.EVERYTHING)))
46
46
  def test_exports_round_trip(style, combo):
47
47
  assert matrix.check_exports(style, matrix.EVERYTHING[combo]) == []
48
+
49
+
50
+ def test_none_padding_and_raw_rows_roundtrip_matrix():
51
+ count, failures = matrix.none_vs_missing(['rounded', 'grid', 'plain',
52
+ 'theme:mono', 'theme:report'])
53
+ assert count == 75
54
+ assert failures == []
@@ -41,11 +41,12 @@ def test_max_width_trims_each_line_of_a_multiline_cell():
41
41
  assert len(_widths(table)) == 1
42
42
 
43
43
 
44
- def test_max_width_trims_none_cells_like_before():
44
+ def test_max_width_renders_none_as_blank_since_v230():
45
45
  table = Table(rows=[[None], ['x']], headers=['c'])
46
46
  table.style_name = 'ascii'
47
47
  table.column_max_width = 3
48
- assert '| ... |' in strip_ansi(table.compose()).splitlines()
48
+ assert '| |' in strip_ansi(table.compose()).splitlines()
49
+ assert 'None' not in table.compose()
49
50
 
50
51
 
51
52
  @pytest.mark.parametrize('style', Table().possible_styles)
@@ -0,0 +1,88 @@
1
+ """None is a missing cell, not the string 'None' (visible change in 2.3)."""
2
+ import pytest
3
+
4
+ from flexablelib import Table
5
+ from flexablelib.style_compositions import __style_compositions as catalogue
6
+ from flexablelib.text_width import visible_width
7
+
8
+
9
+ def make(style, missing, sentinel=False):
10
+ t = Table(headers=['id', 'float', 'int', 'text'], style_name=style,
11
+ missing_val=missing)
12
+ gap = t.missing if sentinel else None
13
+ for row in [['r0', 924.87, 31, '東京 😀'], ['r1', gap, gap, gap],
14
+ ['r2', -1.25, 2, 'épsilon'], ['r3', gap, 107, 'tail']]:
15
+ t.add_row(row)
16
+ t.max_width = 1000
17
+ return t
18
+
19
+
20
+ @pytest.mark.parametrize('style', catalogue._fields)
21
+ @pytest.mark.parametrize('missing', ['', '?', '欠測 😀'])
22
+ def test_none_matches_padding_sentinel_in_every_render_path(style, missing):
23
+ a, b = make(style, missing), make(style, missing, sentinel=True)
24
+ assert a.compose() == b.compose()
25
+ assert str(a) == str(b)
26
+ assert a.paginate(2) == b.paginate(2)
27
+ assert a.paginate(2, freeze_header=False) == b.paginate(2, freeze_header=False)
28
+ assert list(a.stream([])) == list(b.stream([]))
29
+ assert a.transpose().compose() == b.transpose().compose()
30
+ assert a.rows == b.rows
31
+ assert a.to_records() == b.to_records()
32
+ assert a.to_records(formatted=True) == b.to_records(formatted=True)
33
+ assert a.to_csv() == b.to_csv()
34
+ assert a.to_html() == b.to_html()
35
+ assert a.to_markdown() == b.to_markdown()
36
+ assert 'None' not in a.compose()
37
+
38
+
39
+ @pytest.mark.parametrize('missing', ['', '?', 'missing'])
40
+ @pytest.mark.parametrize('index', [False, True])
41
+ def test_none_preserves_numeric_alignment_and_decimal_axis_with_wrap(missing, index):
42
+ t = make('ascii', missing)
43
+ t.show_index = index
44
+ t.overflow = 'wrap'
45
+ t.column_max_width = 7
46
+ out = t.compose()
47
+ lines = out.splitlines()
48
+ assert len({visible_width(line) for line in lines}) == 1
49
+ # A missing cell must not turn numbers into text that wraps over lines.
50
+ assert '924.87' in out
51
+ assert '-1.25' in out
52
+ assert '31 |' in out
53
+ numeric = [line for line in lines if '924.87' in line or '-1.25' in line]
54
+ assert numeric[0].index('.') == numeric[1].index('.')
55
+
56
+
57
+ @pytest.mark.parametrize('style', catalogue._fields)
58
+ def test_rows_roundtrip_keeps_blanks_and_column_types(style):
59
+ t = Table(rows=[[2.75, 3], [None], [24.5, None]], style_name=style)
60
+ assert Table(rows=t.rows, style_name=style).compose() == t.compose()
61
+ t.missing_value = '?'
62
+ copy = Table(rows=t.rows, headers=t.headers, style_name=style, missing_val='?')
63
+ assert copy.compose() == t.compose()
64
+ assert copy.rows == t.rows
65
+
66
+
67
+ def test_stream_incoming_none_matches_an_incoming_padding_sentinel():
68
+ a = Table(headers=['n', 'i'], missing_val='?')
69
+ b = Table(headers=['n', 'i'], missing_val='?')
70
+ for t in (a, b):
71
+ t.column_min_width = 12
72
+ t.max_width = 100
73
+ rows = [[2.75, 3], [None, None], [24.5, 22]]
74
+ sentinel_rows = [[2.75, 3], [b.missing, b.missing], [24.5, 22]]
75
+ assert list(a.stream(rows, append=True)) == list(b.stream(sentinel_rows, append=True))
76
+ assert a.rows == rows
77
+ assert a.compose() == b.compose()
78
+
79
+
80
+ def test_missing_value_is_dynamic_and_storage_stays_raw():
81
+ t = Table(rows=[[None], [2.75]], headers=['n'])
82
+ assert t.rows == [[None], [2.75]]
83
+ assert 'None' not in t.compose()
84
+ t.missing_value = '?'
85
+ assert '?' in t.compose()
86
+ assert t.rows == [[None], [2.75]]
87
+ assert t.to_records() == [{'n': None}, {'n': 2.75}]
88
+ assert t.to_records(formatted=True)[0] == {'n': None}
@@ -364,8 +364,15 @@ def run_case(style, config, header_style=None):
364
364
  continue
365
365
  dict(FACTORS[name])[label](t2)
366
366
  # stream freezes widths before rows arrive; numbers are never
367
- # cut (by design), so give every column room for the widest one.
368
- t2.column_min_width = 14
367
+ # cut (by design), so give every column room for its decimal axis too (including
368
+ # a long integer alongside scientific notation).
369
+ # Numeric columns containing None now remain numeric. A caller's
370
+ # tiny cap/terminal budget cannot be kept as well as an uncut
371
+ # number: stream documents that frozen-width precondition. Test
372
+ # narrow fits in compose/paginate; use a feasible budget here.
373
+ t2.column_min_width = 20
374
+ t2.column_max_width = 20
375
+ t2.max_width = BIG
369
376
  outs = ['\n'.join(t2.stream(make_rows()))]
370
377
  elif mode == 'transpose':
371
378
  outs = [t.transpose().compose()]
@@ -565,6 +572,50 @@ def stream_vs_compose():
565
572
  return n, bad
566
573
 
567
574
 
575
+ def none_vs_missing(styles):
576
+ """None, an internal padding gap, and rows round-trip draw identically."""
577
+ bad, n = [], 0
578
+ for style in styles:
579
+ for missing in ('', '?', '欠測 😀'):
580
+ tables = []
581
+ for sentinel in (False, True):
582
+ t = Table(headers=['id', 'number', 'int'], missing_val=missing)
583
+ if style.startswith('theme:'):
584
+ t.apply_theme(style[6:])
585
+ else:
586
+ t.style_name = style
587
+ gap = t.missing if sentinel else None
588
+ for row in [['r0', 924.87, 31], ['r1', gap, gap],
589
+ ['r2', -1.25, 2]]:
590
+ t.add_row(row)
591
+ t.max_width = BIG
592
+ t.overflow = 'wrap'
593
+ t.column_max_width = 8
594
+ tables.append(t)
595
+ a, b = tables
596
+ clone = Table(rows=a.rows, headers=a.headers, missing_val=missing,
597
+ style_name=a.style_name)
598
+ a._Table__copy_display_settings(clone)
599
+ clone.zebra = a.zebra
600
+ for label, render in (
601
+ ('compose', lambda t: t.compose()),
602
+ ('paginate', lambda t: t.paginate(2)),
603
+ ('paginate_nofreeze', lambda t: t.paginate(2, freeze_header=False)),
604
+ ('stream', lambda t: list(t.stream([]))),
605
+ ('transpose', lambda t: t.transpose().compose()),
606
+ ):
607
+ n += 1
608
+ try:
609
+ expected = render(b)
610
+ if render(a) != expected or render(clone) != expected:
611
+ bad.append({'style': style, 'config': {'mode': label},
612
+ 'problems': [('none-roundtrip', repr(missing))]})
613
+ except Exception as e:
614
+ bad.append({'style': style, 'config': {'mode': label},
615
+ 'problems': [('exception', str(e))]})
616
+ return n, bad
617
+
618
+
568
619
  def main(argv=None):
569
620
  import argparse
570
621
  ap = argparse.ArgumentParser()
@@ -580,6 +631,10 @@ def main(argv=None):
580
631
  results, n = [], 0
581
632
  if a.mode in ('streamcmp', 'all'):
582
633
  n, results = stream_vs_compose()
634
+ if a.mode in ('nonecmp', 'all'):
635
+ count, failures = none_vs_missing(styles)
636
+ n += count
637
+ results.extend(failures)
583
638
  for style, config in iter_cases(a.mode, styles):
584
639
  n += 1
585
640
  probs = run_case(style, config)
File without changes
File without changes
File without changes
File without changes
File without changes