incubator-bloodhound-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrej Golcov <and...@digiverse.si>
Subject Re: Pylint warnings in bhsearch.
Date Wed, 13 Mar 2013 16:13:08 GMT
Thank you, Anze.

Pylint output looks much better now :)
Changes are applied in r1456017.

Cheers, Andrej

On 13 March 2013 16:17, Anze Staric <anze.staric@gmail.com> wrote:
> (As the attachment did not make it to the mailing list, I have coppied
> the content of the patch to the message body).
>
> Index: bloodhound_search/bhsearch/api.py
> ===================================================================
> --- bloodhound_search/bhsearch/api.py (revision 1455913)
> +++ bloodhound_search/bhsearch/api.py (working copy)
> @@ -369,7 +369,9 @@
>          self.upgrade_environment(self.env.db_transaction)
>
>      def environment_needs_upgrade(self, db):
> +        # pylint: disable=unused-argument
>          return self.backend.is_index_outdated()
>
>      def upgrade_environment(self, db):
> +        # pylint: disable=unused-argument
>          self.rebuild_index()
> Index: bloodhound_search/bhsearch/tests/whoosh_backend.py
> ===================================================================
> --- bloodhound_search/bhsearch/tests/whoosh_backend.py (revision 1455913)
> +++ bloodhound_search/bhsearch/tests/whoosh_backend.py (working copy)
> @@ -588,20 +588,20 @@
>              w.add_document(content=u"A nice sentence with stop words.")
>
>          with ix.searcher() as s:
> -            query = u"with stop"
> +            query_text = u"with stop"
>
>              # field_names both ignore stop words
>              q = MultifieldParser(['content', 'summary'],
> -                                 WhooshBackend.SCHEMA).parse(query)
> -            self.assertEqual(q.simplify(s).__unicode__(),
> +                                 WhooshBackend.SCHEMA).parse(query_text)
> +            self.assertEqual(unicode(q.simplify(s)),
>                               u'((content:with OR summary:with) AND '
>                               u'(content:stop OR summary:stop))')
>              self.assertEqual(len(s.search(q)), 1)
>
>              # 'content' and 'id' ignores stop words
>              q = MultifieldParser(['content', 'id'],
> -                                 WhooshBackend.SCHEMA).parse(query)
> -            self.assertEqual(q.simplify(s).__unicode__(),
> +                                 WhooshBackend.SCHEMA).parse(query_text)
> +            self.assertEqual(unicode(q.simplify(s)),
>                               u'((content:with OR id:with) AND '
>                               u'(content:stop OR id:stop))')
>              self.assertEqual(len(s.search(q)), 1)
> Index: bloodhound_search/bhsearch/tests/query_parser.py
> ===================================================================
> --- bloodhound_search/bhsearch/tests/query_parser.py (revision 1455913)
> +++ bloodhound_search/bhsearch/tests/query_parser.py (working copy)
> @@ -21,6 +21,7 @@
>  import unittest
>  from bhsearch.tests.base import BaseBloodhoundSearchTest
>  from bhsearch.query_parser import DefaultQueryParser
> +from trac.test import Mock
>  from whoosh.query import terms, nary, wrappers
>
>
> @@ -84,9 +85,11 @@
>          self.assertEqual(parsed_query, terms.Term('owner', 'username'))
>
>      def _mock_context_with_username(self, username):
> -        class context:
> -            class req:
> -                authname = username
> +        context = Mock(
> +            req=Mock(
> +                authname=username
> +            )
> +        )
>          return context
>
>
> Index: bloodhound_search/bhsearch/whoosh_backend.py
> ===================================================================
> --- bloodhound_search/bhsearch/whoosh_backend.py (revision 1455913)
> +++ bloodhound_search/bhsearch/whoosh_backend.py (working copy)
> @@ -227,7 +227,8 @@
>                                              highlight_fields,
>                                              query_parameters)
>              try:
> -                results.debug['actual_query'] =
> unicode(query.simplify(searcher))
> +                actual_query = unicode(query.simplify(searcher))
> +                results.debug['actual_query'] = actual_query
>              except TypeError:
>                  # Simplify has a bug that causes it to fail sometimes.
>                  pass
> Index: bloodhound_search/bhsearch/query_parser.py
> ===================================================================
> --- bloodhound_search/bhsearch/query_parser.py (revision 1455913)
> +++ bloodhound_search/bhsearch/query_parser.py (working copy)
> @@ -131,6 +131,7 @@
>      search_participants = ExtensionPoint(ISearchParticipant)
>
>      def match(self, text, context):
> +        # pylint: disable=unused-argument
>          documents = [p.get_participant_type()
>                       for p in self.search_participants]
>          if text in documents:
> @@ -141,6 +142,7 @@
>      implements(IMetaKeywordParser)
>
>      def match(self, text, context):
> +        # pylint: disable=unused-argument
>          if text == u'resolved':
>              return u'status:(resolved OR closed)'
>
> @@ -149,6 +151,7 @@
>      implements(IMetaKeywordParser)
>
>      def match(self, text, context):
> +        # pylint: disable=unused-argument
>          if text == u'unresolved':
>              return u'NOT $resolved'
>
> @@ -166,5 +169,6 @@
>      implements(IMetaKeywordParser)
>
>      def match(self, text, context):
> +        # pylint: disable=unused-argument
>          if text == u'my':
>              return u'owner:$me'
>
> On Wed, Mar 13, 2013 at 4:01 PM, Anze Staric <anze.staric@gmail.com> wrote:
>> I have noticed that the patches I have produced for bhsearch cause
>> some pylint warnings. Attached patch fixes the ones I could fix and
>> silences the rest.
>>
>> Can someone please check it out and, if it is ok, commits it?
>>
>>
>> Thanks,
>> Anze

Mime
View raw message