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

aspectbase: Recursively instance aspect children #4427

Merged
merged 2 commits into from Jul 13, 2017

Conversation

5 participants
@adhikasp
Member

adhikasp commented Jun 30, 2017

Modify aspectbase constructor to recursively init their children
subaspects.

Note that accessing child instance MUST be done through .subaspects
dict.

>>> commit_msg = coala_aspects['CommitMessage']('py')
>>> commit_msg
<...Metadata.CommitMessage object at 0x...>
>>> commit_msg.subaspects
{'Emptiness': <...CommitMessage.Emptiness object at 0x...>,
'Shortlog': <...CommitMessage.Shortlog object at 0x...>, ...}
>>> commit_msg.subaspects['Emptiness'] # Got instance
<..CommitMessage.Emptiness object at 0x...>
>>> commit_msg.Emptiness # Got aspectclass instead
<aspectclass 'Root.Metadata.CommitMessage.Emptiness'>

We can also set children taste through its parent.

>>> commit_msg = coala_aspects['CommitMessage'] ('py', shortlog_tense='past')
>>> commit_msg.subaspects['Shortlog'].subaspects['Tense']
<Tense object(shortlog_tense='past') at 0x...>

Fixes #4388

area/aspects @userzimmermann

@jayvdb

test_instantiation needs to assert that it did recurse . I.e. at the moment, it could do nothing and pass. Add a counter, and assert the final counter value .

@adhikasp

This comment has been minimized.

Member

adhikasp commented Jul 6, 2017

@jayvdb I add counter to the test

@jayvdb

jayvdb approved these changes Jul 6, 2017

@jayvdb

jayvdb approved these changes Jul 12, 2017

@jayvdb

This comment has been minimized.

Member

jayvdb commented Jul 12, 2017

ack 54a212b 735c13d

adhikasp added some commits Jun 30, 2017

aspectbase: Recursively instance aspect children
Modify aspectbase constructor to recursively init their children
subaspects.

Note that accessing child instance MUST be done through `.subaspects`
dict.

```python
>>> commit_msg = coala_aspects['CommitMessage']('py')
>>> commit_msg
<...Metadata.CommitMessage object at 0x...>
>>> commit_msg.subaspects
{'Emptiness': <...CommitMessage.Emptiness object at 0x...>,
'Shortlog': <...CommitMessage.Shortlog object at 0x...>, ...}
>>> commit_msg.subaspects['Emptiness'] # Got instance
<..CommitMessage.Emptiness object at 0x...>
>>> commit_msg.Emptiness # Got aspectclass instead
<aspectclass 'Root.Metadata.CommitMessage.Emptiness'>
```

We can also set children taste through its parent.

```python
>>> commit_msg = coala_aspects['CommitMessage'] \
>>> ('py', shortlog_tense='past')
>>> commit_msg.subaspects['Shortlog'].subaspects['Tense']
<Tense object(shortlog_tense='past') at 0x...>
```

Fixes #4388
@jayvdb

This comment has been minimized.

Member

jayvdb commented Jul 13, 2017

@jayvdb

This comment has been minimized.

Member

jayvdb commented Jul 13, 2017

@rultor merge

@rultor

This comment has been minimized.

Contributor

rultor commented Jul 13, 2017

@rultor merge

@jayvdb OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 847e453 into coala:master Jul 13, 2017

6 of 9 checks passed

ci/circleci CircleCI is running your tests
Details
continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
codecov/project 100% (target 100%)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
review/gitmate/commit No issues with this one - go ahead! :)
Details
review/gitmate/manual This commit was acknowledged.
Details
review/gitmate/pr All is well! :) (0 problems solved)
Details
@rultor

This comment has been minimized.

Contributor

rultor commented Jul 13, 2017

@rultor merge

@jayvdb Done! FYI, the full log is here (took me 2min)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment