You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bloodhound.apache.org by Anze Staric <an...@gmail.com> on 2013/03/13 16:01:44 UTC

Pylint warnings in bhsearch.

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

Re: Pylint warnings in bhsearch.

Posted by Andrej Golcov <an...@digiverse.si>.
Thank you, Anze.

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

Cheers, Andrej

On 13 March 2013 16:17, Anze Staric <an...@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 <an...@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

Re: Pylint warnings in bhsearch.

Posted by Anze Staric <an...@gmail.com>.
(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 <an...@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

Re: Pylint warnings in bhsearch.

Posted by Branko Čibej <br...@wandisco.com>.
On 13.03.2013 16:01, Anze Staric 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?

Love to, but you have to attach the patch first. :)

-- Brane


-- 
Branko Čibej
Director of Subversion | WANdisco | www.wandisco.com