Skip to content

DB usability improvements#385

Merged
gijzelaerr merged 3 commits into
gijzelaerr:masterfrom
vmsh0:db-usability-improvements
Sep 21, 2022
Merged

DB usability improvements#385
gijzelaerr merged 3 commits into
gijzelaerr:masterfrom
vmsh0:db-usability-improvements

Conversation

@vmsh0

@vmsh0 vmsh0 commented Aug 22, 2022

Copy link
Copy Markdown
Contributor

In reference to Issues #379 and #380, I'm opening this PR with proposed improvements for the DB class.

Please let me know whether there's anything I can change/improve to get this pulled.

vmsh0 added 2 commits August 22, 2022 16:44
util.DB is a wrapper class to manipulate data in tabular format. before
this commit, it was not possible to read or write the entire table in
one go. this commit introduces support for such operations.

the rationale of these operations is to have the ability to operate on
the entire table in the same way it is possible to operate on the single
rows, without requiring external iteration.
implement keys(), items(), __contains__() methods for the DB class with
dict-like semantics. implement an export() method, flattening the entire
structure (DB and DB_Row's), with semantics akin to DB_Row.export().

document in more detail the existing dict-like semantics of the DB
class, detailing in particular the instances where the existing
behaviour diverges from Python dicts.

introduce an unit test for the new DB.export() method.
@vmsh0
vmsh0 force-pushed the db-usability-improvements branch from b8a2f84 to f02a8c5 Compare August 22, 2022 15:15
the existing type hints make some attributes Optional, while a None
value for any of those attribute would be in fact an error.

there might be more esuch cases in the DB class: this commit is not
meant to be exhaustive.
@vmsh0
vmsh0 force-pushed the db-usability-improvements branch from f02a8c5 to 16035e3 Compare August 22, 2022 15:19
@vmsh0

vmsh0 commented Aug 22, 2022

Copy link
Copy Markdown
Contributor Author

As you can see, I also added some static typing fixes that seemed appropriate. Existing code, as well as some of my new code, failed static typechecks without those fixes.

In particular, None values for some of the numeric parameters of DB where accepted for some of the instance attributes. This doesn't make sense as:

  • None values are not semantically valid for those members
  • They all have a well-defined (and useful) default

@gijzelaerr
gijzelaerr self-requested a review September 21, 2022 06:45
@gijzelaerr
gijzelaerr merged commit a55d938 into gijzelaerr:master Sep 21, 2022
@gijzelaerr gijzelaerr added this to the 1.3 milestone Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants