Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 196 #200

Merged
merged 4 commits into from
Jan 3, 2022
Merged

Issue 196 #200

merged 4 commits into from
Jan 3, 2022

Conversation

ncilfone
Copy link
Contributor

@ncilfone ncilfone commented Jan 3, 2022

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

  • Did you adhere to PEP-8 standards?
  • Did you run black and isort prior to submitting your PR?
  • Does your PR pass all existing unit tests?
  • Did you add associated unit tests for any additional functionality?
  • Did you provide documentation (Google Docstring format) whenever possible, even for simple functions or classes?

…st def they now get caught via a instance check within the list field handlers. Added tests for coded defaults
@ncilfone ncilfone added bug Something isn't working tests Unit tests labels Jan 3, 2022
@ncilfone ncilfone self-assigned this Jan 3, 2022
@coveralls
Copy link

coveralls commented Jan 3, 2022

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

  • 10 of 11 (90.91%) changed or added relevant lines in 2 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.09%) to 95.201%

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

💛 - Coveralls

@ncilfone
Copy link
Contributor Author

ncilfone commented Jan 3, 2022

@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.

…ted classes. If no config values are passed or defaults are coded it will fall back on the base classes defaults and instantate a list of length equal to the number of class instances specified in the default constructor.
@ncilfone ncilfone marked this pull request as ready for review January 3, 2022 19:36
@ncilfone ncilfone merged commit d8eee88 into master Jan 3, 2022
@ncilfone ncilfone linked an issue Jan 3, 2022 that may be closed by this pull request
@ncilfone ncilfone deleted the issue_196 branch January 4, 2022 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tests Unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default values of nested list with items is a spock class.
2 participants