fidelity / spock

spock is a framework that helps manage complex parameter configurations during research and development of Python applications
https://fidelity.github.io/spock/
Apache License 2.0
122 stars 13 forks source link

Issue 196 #200

Closed ncilfone closed 2 years ago

ncilfone commented 2 years ago

What does this PR do?

Handles #196

  1. Addresses defining repeated classes via coded defaults:
nested_list_def: List[NestedListStuff] = [NestedListStuff, NestedListStuff(one=1, two="two"), NestedListStuff(one=3, two="four")]
  1. Handles semantics for defining the default values of repeated classes. Will now attempt to fallback on base class specified defaults if available:
nested_list_def: List[NestedListStuff] = [NestedListStuff]

will default to a list of length 1 initialized with NestedListStuff default attribute values

nested_list_def: List[NestedListStuff] = [NestedListStuff, NestedListStuff]

will default to a list of length 2, both initialized with NestedListStuff default attribute values.

This now allows for mixing defaults as well:

nested_list_def: List[NestedListStuff] = [NestedListStuff, NestedListStuff(one=3, two="four")]

where the class instantiated at pos [0] is initialized with NestedListStuff default attribute values while the class instantiated at pos[1] will be the coded defaults.

Checklist

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 1650691463

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
spock/backend/field_handlers.py 9 10 90.0%
<!-- Total: 10 11 90.91% -->
Files with Coverage Reduction New Missed Lines %
spock/backend/field_handlers.py 3 93.96%
<!-- Total: 3 -->
Totals Coverage Status
Change from base Build 1649888142: 0.09%
Covered Lines: 1607
Relevant Lines: 1688

💛 - Coveralls
ncilfone commented 2 years ago

@gbmarc1 Addresses defining repeated classes via coded defaults e.g.

nested_list_def: List[NestedListStuff] = [NestedListStuff, NestedListStuff(one=1, two="two"), NestedListStuff(one=3, two="four")]

This should work now. Need to catch some exceptions etc. to make it fail cleanly so it's still WIP.