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
Add docs on writing aspect bear #4666
Conversation
https://github.com/coala/cEPs/blob/master/cEP-0005.md. | ||
|
||
An aspect-compliant bear MUST: | ||
1. Declare list of aspect it can fix and detected. Note that the aspect MUST be |
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.
Blank line here
3. Map setting to its equivalent aspect or taste using ``map_setting_to_aspect`` | ||
decorator. | ||
4. Anotate yielded result with ``aspect``. | ||
|
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.
Annotate*
f1b488e
to
ad80c25
Compare
coalib/bearlib/aspects/decorators.py
Outdated
""" | ||
Override function arguments value with coala's aspect and taste. | ||
|
||
This decorators could be used by ``Bear.run()`` to automatically map and |
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.
Suggestion: decorator can* might be better
it looks good to me |
This is waiting on #4662 |
ad80c25
to
983a137
Compare
def run(self, | ||
filename, | ||
file, | ||
use_standard_dictionary:bool=True, |
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.
We typically have a space after :
, which is the general style at https://www.python.org/dev/peps/pep-0484/
languages=['Python']): | ||
|
||
@map_setting_to_aspect( | ||
use_standard_dictionary=DictionarySpelling |
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.
comma not needed here??
please run your sample code through linters.
class SpellingCheckBear( | ||
LocalBear, | ||
aspect={ | ||
'detect': [DictionarySpelling, OrgSpecificWordSpelling] |
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.
trailing comma
if word not in dictionary_words: | ||
yield self.new_result( | ||
message='Wrong spelling', | ||
additional_info=(DictionarySpelling.docs |
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.
shouldnt DictionarySpelling.docs.importance_reason
be the default value for additional_info
?
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.
Yes it should be. If you mean
If result have
aspect
arg, it should be defaulting to useaspect.docs.importance_reason
then, no, it is not implemented yet.
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.
Is there a bug about it?! If not, please create one!
This would fall in your main project scope, of making it easy to use 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.
Created #4680
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.
That issue is included in this PR too.
for word in file.split(): | ||
if word not in dictionary_words: | ||
yield self.new_result( | ||
message='Wrong spelling', |
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.
this message should include the value of word
# Imagine this is where we save our standard dictionary. | ||
dictionary_words = ['lorem', 'ipsum'] | ||
|
||
if not use_standard_dictionary: |
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.
this logic is tortured.
use
if ...:
dictionary_words = ['lorem', 'ipsum']
else:
dictionary_words = []
983a137
to
ed6fade
Compare
57495c0
to
c5c32cf
Compare
Contain additional commit to fix #4682 |
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.
not tested properly.
3d7c408
to
f23ba94
Compare
ba4fb51
to
3c81460
Compare
3c81460
to
d41d691
Compare
ack d41d691 |
rebase and LGTM |
Relates to coala#4665
d41d691
to
8c9141c
Compare
reack 8c9141c |
@rultor merge |
Relates to #4665
Contain commit from #4662