Skip to content

2.3.0 - New `collections` module + refactoring

Compare
Choose a tag to compare
@Someguy123 Someguy123 released this 01 Dec 03:15
· 56 commits to master since this release

This is the final version of 2.3.0 (as published to PyPi) - merged from develop branch.

Includes the following extra commits since original release:

  • (commit 600cccd) Rename test_tuple to test_collections + add TestDictObject

  • (commit fa1f4db) Re-factored dictable_namedtuple and related functions for py3.6 / 3.7 compat

Minor updates

  • docs/source/conf.py now sets PYTHON_PATH which helps reduce issues with Sphinx
    finding the privex package folder

  • Fleshed out docs/source/examples.rst with DictObject and dictable_namedtuple examples.

  • Added documentation for privex.helpers.collections and tests.test_collections

  • Added Pipfile and Pipfile.lock for use with pipenv during development

Major changes

  • Created module privex.helpers.collections

    • DictObject - A dict sub-class which allows keys to be read/written via
      attributes (x.something) as well as standard item/key notation (x['something'])

    • MockDictObj - Same as DictObject, but masquerades as the builtin dict, potentially
      allowing it to be used with certain code that expects the builtin dict type

    • is_namedtuple - Boolean function which returns True if all passed objects are named tuples

    • dictable_namedtuple - An improved version of the native collections.namedtuple, which adds additional functionality
      such as dict-like key/item access to fields, ability to cast directly to a dict, and ability to add new fields
      dynamically to an existing instance.

    • convert_dictable_namedtuple - Converts a namedtuple type class instance into a dictable_namedtuple instance

    • subclass_dictable_namedtuple - Converts a namedtuple type/class into a dictable_namedtuple type/class

  • Created unit tests for is_namedtuple and dictable_namedtuple in tests/test_collections.py

BREAKING CHANGES

  • Mocker has been moved from privex.helpers.common into privex.helpers.collections.
    Code which imports via from privex.helpers.common import Mocker will no longer work.
    Code which imports Mocker from the shared privex.helpers module (i.e. from privex.helpers import Mocker)
    should be unaffected.

  • Dictable has been moved from privex.helpers.common into privex.helpers.collections.
    Code which imports via from privex.helpers.common import Dictable will no longer work.
    Code which imports Dictable from the shared privex.helpers module (i.e. from privex.helpers import Dictable)
    should be unaffected.