Suppress add_table write-only warning if tableColumns is not empty
The "In write-only mode you must add table columns manually" warning is issued at all times in write-only mode, even if usage is correct. However, in my opinion, the warning should automatically be suppressed if it's clear the user has taken steps to mitigate the problem.
This would help new users understand when the issue is resolved. I personally spent a couple hours trying to understand why the warning wasn't going away before deciding to check the source code.
The following simple fix should at least serve as a suppression mechanism: if the user has set tableColumns
, they're already handling columns manually. Ideally, a more thorough check could be performed to determine if the TableColumn
s are configured properly.
if self.parent._duplicate_name(table.name):
raise ValueError("Table with name {0} already exists".format(table.name))
- if not hasattr(self, "_get_cell"):
+ if not hasattr(self, "_get_cell") and not table.tableColumns:
warn("In write-only mode you must add table columns manually")
self._tables.add(table)
The need for the warning was already discussed in #1760 (closed).