(core) A few tiny documentation tweaks.

Summary:
- Improve readability of documentation of CONTAINS.
- Add leading underscore to Record._get_encodable_row_ids() to hide from
  public docs, and avoid interfering with user fields.
- Fix up lint errors

Test Plan: No behavior changes

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3209
This commit is contained in:
Dmitry S 2022-01-06 18:58:54 -05:00
parent 596bd194d5
commit b37b8a9f6d
5 changed files with 14 additions and 6 deletions

View File

@ -154,7 +154,9 @@ def VLOOKUP(table, **field_value_pairs):
class _Contains(namedtuple("_Contains", "value")): class _Contains(namedtuple("_Contains", "value")):
""" """
Use this marker with [UserTable.lookupRecords](#lookuprecords) to find records Use this marker with [UserTable.lookupRecords](#lookuprecords) to find records
where a field of a list type (such as `Choice List` or `Reference List`) contains the given value, e.g: where a field of a list type (such as `Choice List` or `Reference List`) contains the given value.
For example:
MoviesTable.lookupRecords(genre=CONTAINS("Drama")) MoviesTable.lookupRecords(genre=CONTAINS("Drama"))

View File

@ -612,6 +612,8 @@ def ROUND(value, places=0):
2.0 2.0
>>> ROUND(2.5) >>> ROUND(2.5)
3.0 3.0
>>> ROUND(-2.5)
-3.0
>>> ROUND(2.15, 1) >>> ROUND(2.15, 1)
2.2 2.2
>>> ROUND(-1.475, 2) >>> ROUND(-1.475, 2)

View File

@ -190,7 +190,7 @@ def encode_object(value):
elif isinstance(value, (list, tuple)): elif isinstance(value, (list, tuple)):
return ['L'] + [encode_object(item) for item in value] return ['L'] + [encode_object(item) for item in value]
elif isinstance(value, records.RecordSet): elif isinstance(value, records.RecordSet):
return ['r', value._table.table_id, value.get_encodable_row_ids()] return ['r', value._table.table_id, value._get_encodable_row_ids()]
elif isinstance(value, RecordSetStub): elif isinstance(value, RecordSetStub):
return ['r', value.table_id, value.row_ids] return ['r', value.table_id, value.row_ids]
elif isinstance(value, dict): elif isinstance(value, dict):

View File

@ -133,6 +133,8 @@ class RecordSet(object):
You can get the number of records in a RecordSet using `len`, e.g. `len($group)`. You can get the number of records in a RecordSet using `len`, e.g. `len($group)`.
""" """
# Methods should be named with a leading underscore to avoid interfering with access to
# user-defined fields.
def __init__(self, table, row_ids, relation=None, group_by=None, sort_by=None): def __init__(self, table, row_ids, relation=None, group_by=None, sort_by=None):
""" """
group_by may be a dictionary mapping column names to values that are all the same for the given group_by may be a dictionary mapping column names to values that are all the same for the given
@ -194,7 +196,7 @@ class RecordSet(object):
group_by=self._group_by, group_by=self._group_by,
sort_by=self._sort_by) sort_by=self._sort_by)
def get_encodable_row_ids(self): def _get_encodable_row_ids(self):
""" """
Returns stored rowIds as a simple list or tuple type, even if actually stored as RecordList. Returns stored rowIds as a simple list or tuple type, even if actually stored as RecordList.
""" """

View File

@ -90,8 +90,9 @@ class UserTable(object):
See [RecordSet](#recordset) for useful properties offered by the returned object. See [RecordSet](#recordset) for useful properties offered by the returned object.
See [CONTAINS](#contains) for an example utilizing `UserTable.lookupRecords` to find records where See [CONTAINS](#contains) for an example utilizing `UserTable.lookupRecords` to find records
a field of a list type (such as `Choice List` or `Reference List`) contains the given value. where a field of a list type (such as `Choice List` or `Reference List`) contains the given
value.
""" """
return self.table.lookup_records(**field_value_pairs) return self.table.lookup_records(**field_value_pairs)
@ -356,6 +357,7 @@ class Table(object):
col_id = summary_table._summary_helper_col_id col_id = summary_table._summary_helper_col_id
if self.has_column(col_id): if self.has_column(col_id):
# If type changed between Reference/ReferenceList, replace completely. # If type changed between Reference/ReferenceList, replace completely.
# pylint: disable=unidiomatic-typecheck
if type(self.get_column(col_id).type_obj) != type(_updateSummary.grist_type): if type(self.get_column(col_id).type_obj) != type(_updateSummary.grist_type):
self.delete_column(self.get_column(col_id)) self.delete_column(self.get_column(col_id))
col_obj = self._create_or_update_col(col_id, _updateSummary) col_obj = self._create_or_update_col(col_id, _updateSummary)