-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
AspectList: Overload __init__ to accept strings #4389
Conversation
@@ -1,3 +1,4 @@ | |||
import coalib.bearlib.aspects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W291 trailing whitespace'
PycodestyleBear (W291), severity NORMAL, section autopep8
.
@@ -1,3 +1,4 @@ | |||
import coalib.bearlib.aspects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not comply to PEP8.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/coalib/bearlib/aspects/collections.py
+++ b/coalib/bearlib/aspects/collections.py
@@ -1,4 +1,4 @@
-import coalib.bearlib.aspects
+import coalib.bearlib.aspects
from coalib.bearlib.aspects.meta import issubaspect, assert_aspect
@@ -1,3 +1,4 @@ | |||
import coalib.bearlib.aspects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains following spacing inconsistencies:
- Trailing whitespaces.
SpaceConsistencyBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/coalib/bearlib/aspects/collections.py
+++ b/coalib/bearlib/aspects/collections.py
@@ -1,4 +1,4 @@
-import coalib.bearlib.aspects
+import coalib.bearlib.aspects
from coalib.bearlib.aspects.meta import issubaspect, assert_aspect
eef77c2
to
62093d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adhikasp Good approach but doesn't handle mixed cases :/
instance, or string of partial/full qualified aspect name. | ||
""" | ||
if all(map((lambda x: isinstance(x, str)), seq)): | ||
seq = map((lambda x: coalib.bearlib.aspects[x]), seq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't cover mixed cases like aspectlist([Root.Spelling.coalaCorrect, 'aspectsYEAH'])
Better super().__init__(item if isaspect(item) else coalib.bearlib.aspects[item] for item in seq)
@@ -9,10 +9,15 @@ | |||
class aspectlistTest: | |||
|
|||
def test__init__(self): | |||
with pytest.raises(aspectTypeError) as exc: | |||
list_of_aspect = aspectlist(['CommitMessage.Shortlog', | |||
'CommitMessage.Body']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test aspectclass/instance/string-only and mixed cases
>>> aspectlist([Root.Spelling.coalaCorrect, Root.Spelling.aspectsYEAH]) | ||
[<aspectclass '...coalaCorrect'>, <aspectclass '...aspectsYEAH'>] | ||
>>> aspectlist(['coalaCorrect', 'aspectsYEAH']) | ||
[<aspectclass '...coalaCorrect'>, <aspectclass '...aspectsYEAH'>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add mixed cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And please add Relates to https://gitlab.com/coala/GSoC-2017/issues/299
to the commit message
62093d6
to
a530545
Compare
@userzimmermann updated |
dd480b6
to
497adf7
Compare
497adf7
to
b8a7d27
Compare
aspectlist(['String']) | ||
exc.match("'String' is not an aspectclass or " | ||
'an instance of an aspectclass') | ||
exc.match("no aspect named 'String'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exception messages should begin with a capital letter: No aspect named ...
Please raise a bug to fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've raised #4402
|
||
>>> from .root import Root | ||
>>> from .Spelling import Spelling | ||
>>> aspectlist([Root.Spelling.coalaCorrect, Root.Spelling.aspectsYEAH]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4401 should be fixed first, otherwise lots of unnecessary changes occur.
b8a7d27
to
c6cb0bb
Compare
6204bf9
to
23220da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit message needs updating to reflect fixed class name.
23220da
to
f7370cc
Compare
0d5143b
to
928d39f
Compare
'CommitMessage.Body']) | ||
mix_of_aspect = AspectList(['CommitMessage.Shortlog', | ||
Metadata.CommitMessage.Body]) | ||
assert isinstance(list_of_aspect, AspectList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace assert
with self.assert...(...)
(This was mentioned to you in another PR just merged; fix all of your PRs)
Overload AspectList so it could be instanced from a list of string containing aspects name. The reason of this overloading is to make it possible to instanced list of desired aspects name found in coafiles. ```python >>> AspectList(['coalaCorrect', 'aspectsYEAH']) [<aspectclass '...coalaCorrect'>, <aspectclass '...aspectsYEAH'>] ``` Replacement of coala#4379 Closes coala#4382
928d39f
to
852ba5e
Compare
ack 852ba5e |
@Tultor merge |
@rultor merge |
@adhikasp @jayvdb This was merged a bit too early. It misses tests with aspect instances as mentioned in #4389 (comment) . But anyway... We can add that later ;) |
Overload aspectlist so it could be instanced from a list of string
containing aspects name. The reason of this overloading is to make
it possible to instanced list of desired aspects found in coafile.
Replacement of #4379
Closes #4382