Repository: barrust/mediawiki

Issue:
DisambiguationError gives incorrect titles of possible results
The `title`s of possible results given in the `details` property of a `DisambiguationError` can be incorrect. They can be the full text of the list item on the disambiguation page describing the possible result, rather than just the title of the possible result page.

Example:

```python
from mediawiki import MediaWiki, DisambiguationError
wikipedia = MediaWiki()

try:
    p = wikipedia.page("Lincoln Museum")
except DisambiguationError as d:
    print(d.details[5]['title'])
    print(d.details[5]['description'])
```

gives

```
Ford's Theatre, Washington, DC, USA — where Abraham Lincoln was assassinated; known as Lincoln Museum from 1936 to 1965 and legally "Ford's Theater (Lincoln Museum)" since 1965
Ford's Theatre, Washington, DC, USA — where Abraham Lincoln was assassinated; known as Lincoln Museum from 1936 to 1965 and legally "Ford's Theater (Lincoln Museum)" since 1965
```

when what is expected is

```
Ford's Theatre
Ford's Theatre, Washington, DC, USA — where Abraham Lincoln was assassinated; known as Lincoln Museum from 1936 to 1965 and legally "Ford's Theater (Lincoln Museum)" since 1965
```

affected version: 0.6.0

Discussion:

Patch:
diff --git a/.pylintrc b/.pylintrc
index 7299369..a91c15e 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -59,7 +59,7 @@ confidence=
 # --enable=similarities". If you want to run only the classes checker, but have
 # no Warning level messages displayed, use"--disable=all --enable=classes
 # --disable=W"
-disable=parameter-unpacking,raw_input-builtin,useless-suppression,unpacking-in-except,dict-iter-method,getslice-method,long-builtin,delslice-method,map-builtin-not-iterating,coerce-method,coerce-builtin,execfile-builtin,round-builtin,old-octal-literal,using-cmp-argument,dict-view-method,cmp-method,next-method-called,indexing-exception,unicode-builtin,oct-method,old-raise-syntax,old-division,xrange-builtin,print-statement,cmp-builtin,old-ne-operator,nonzero-method,metaclass-assignment,import-star-module-level,backtick,unichr-builtin,intern-builtin,reload-builtin,apply-builtin,file-builtin,basestring-builtin,raising-string,long-suffix,zip-builtin-not-iterating,reduce-builtin,hex-method,no-absolute-import,standarderror-builtin,range-builtin-not-iterating,setslice-method,suppressed-message,input-builtin,buffer-builtin,filter-builtin-not-iterating
+disable=parameter-unpacking,raw_input-builtin,useless-suppression,unpacking-in-except,dict-iter-method,getslice-method,long-builtin,delslice-method,map-builtin-not-iterating,coerce-method,coerce-builtin,execfile-builtin,round-builtin,old-octal-literal,using-cmp-argument,dict-view-method,cmp-method,next-method-called,indexing-exception,unicode-builtin,oct-method,old-raise-syntax,old-division,xrange-builtin,print-statement,cmp-builtin,old-ne-operator,nonzero-method,metaclass-assignment,import-star-module-level,backtick,unichr-builtin,intern-builtin,reload-builtin,apply-builtin,file-builtin,basestring-builtin,raising-string,long-suffix,zip-builtin-not-iterating,reduce-builtin,hex-method,no-absolute-import,standarderror-builtin,range-builtin-not-iterating,setslice-method,suppressed-message,input-builtin,buffer-builtin,filter-builtin-not-iterating,bad-continuation
 
 
 [REPORTS]
diff --git a/mediawiki/exceptions.py b/mediawiki/exceptions.py
index bddf08b..d31858f 100644
--- a/mediawiki/exceptions.py
+++ b/mediawiki/exceptions.py
@@ -102,7 +102,8 @@ class RedirectError(MediaWikiBaseException):
     def __init__(self, title):
         self._title = title
         msg = (
-            '"{0}" resulted in a redirect. Set the redirect property to True to allow automatic redirects.'
+            '"{0}" resulted in a redirect. Set the redirect property to True '
+            "to allow automatic redirects."
         ).format(self.title)
 
         super(RedirectError, self).__init__(msg)
@@ -166,8 +167,9 @@ class HTTPTimeoutError(MediaWikiBaseException):
     def __init__(self, query):
         self._query = query
         msg = (
-            'Searching for "{0}" resulted in a timeout. Try again in a few seconds, '
-            "and ensure you have rate limiting set to True."
+            'Searching for "{0}" resulted in a timeout. '
+            "Try again in a few seconds, and ensure you have rate limiting "
+            "set to True."
         ).format(self.query)
         super(HTTPTimeoutError, self).__init__(msg)
 
@@ -204,7 +206,8 @@ class MediaWikiGeoCoordError(MediaWikiBaseException):
     def __init__(self, error):
         self._error = error
         msg = (
-            "GeoData search resulted in the following error: {0} - Please use valid coordinates or a proper page title."
+            "GeoData search resulted in the following error: {0}"
+            " - Please use valid coordinates or a proper page title."
         ).format(self.error)
         super(MediaWikiGeoCoordError, self).__init__(msg)
 
diff --git a/mediawiki/mediawiki.py b/mediawiki/mediawiki.py
index c88e314..b341aed 100644
--- a/mediawiki/mediawiki.py
+++ b/mediawiki/mediawiki.py
@@ -732,7 +732,6 @@ class MediaWiki(object):
                         categories,
                         links,
                     )
-            return
 
         # ###################################
         # ### Actual Function Code        ###
@@ -878,7 +877,7 @@ class MediaWiki(object):
             http_error = ["HTTP request timed out.", "Pool queue is full"]
             geo_error = [
                 "Page coordinates unknown.",
-                ("One of the parameters gscoord, gspage, gsbbox is " "required"),
+                "One of the parameters gscoord, gspage, gsbbox is required",
                 "Invalid coordinate provided",
             ]
             err = response["error"]["info"]
diff --git a/mediawiki/mediawikipage.py b/mediawiki/mediawikipage.py
index abe190b..dcdf5eb 100644
--- a/mediawiki/mediawikipage.py
+++ b/mediawiki/mediawikipage.py
@@ -536,7 +536,7 @@ class MediaWikiPage(object):
             item = lis_item.find_all("a")
             one_disambiguation = dict()
             one_disambiguation["description"] = lis_item.text
-            if item and hasattr(item, "title"):
+            if item and hasattr(item[0], "title"):
                 one_disambiguation["title"] = item[0]["title"]
             else:
                 # these are non-linked records so double up the text


Test patch:
diff --git a/tests/mock_responses.json b/tests/mock_responses.json
index c2d2791..9c7fc30 100644
--- a/tests/mock_responses.json
+++ b/tests/mock_responses.json
@@ -6239,43 +6239,43 @@
   "missing_title_disamb_dets": [
    {
     "description": "Leaching (agriculture), the loss of water-soluble plant nutrients from the soil; or applying a small amount of excess irrigation to avoid soil salinity",
-    "title": "Leaching (agriculture), the loss of water-soluble plant nutrients from the soil; or applying a small amount of excess irrigation to avoid soil salinity"
+    "title": "Leaching (agriculture)"
    },
    {
     "description": "Leaching (chemistry), the process of extracting substances from a solid by dissolving them in a liquid",
-    "title": "Leaching (chemistry), the process of extracting substances from a solid by dissolving them in a liquid"
+    "title": "Leaching (chemistry)"
    },
    {
     "description": "Leaching (metallurgy), a widely used extractive metallurgy technique which converts metals into soluble salts in aqueous media\nDump leaching, an industrial process to extract metals from ore taken directly from the mine and stacked on the leach pad without crushing\nHeap leaching, an industrial process to extract metals from ore which has been crushed into small chunks\nTank leaching, a hydro metallurgical method of extracting valuable material from ore\nIn-situ leaching, a process of recovering minerals such as copper and uranium through boreholes drilled into the deposit",
-    "title": "Leaching (metallurgy), a widely used extractive metallurgy technique which converts metals into soluble salts in aqueous media\nDump leaching, an industrial process to extract metals from ore taken directly from the mine and stacked on the leach pad without crushing\nHeap leaching, an industrial process to extract metals from ore which has been crushed into small chunks\nTank leaching, a hydro metallurgical method of extracting valuable material from ore\nIn-situ leaching, a process of recovering minerals such as copper and uranium through boreholes drilled into the deposit"
+    "title": "Leaching (metallurgy)"
    },
    {
     "description": "Dump leaching, an industrial process to extract metals from ore taken directly from the mine and stacked on the leach pad without crushing",
-    "title": "Dump leaching, an industrial process to extract metals from ore taken directly from the mine and stacked on the leach pad without crushing"
+    "title": "Dump leaching"
    },
    {
     "description": "Heap leaching, an industrial process to extract metals from ore which has been crushed into small chunks",
-    "title": "Heap leaching, an industrial process to extract metals from ore which has been crushed into small chunks"
+    "title": "Heap leaching"
    },
    {
     "description": "Tank leaching, a hydro metallurgical method of extracting valuable material from ore",
-    "title": "Tank leaching, a hydro metallurgical method of extracting valuable material from ore"
+    "title": "Tank leaching"
    },
    {
     "description": "In-situ leaching, a process of recovering minerals such as copper and uranium through boreholes drilled into the deposit",
-    "title": "In-situ leaching, a process of recovering minerals such as copper and uranium through boreholes drilled into the deposit"
+    "title": "In-situ leaching"
    },
    {
     "description": "Leaching (pedology), the loss of mineral and organic solutes due to percolation from soil",
-    "title": "Leaching (pedology), the loss of mineral and organic solutes due to percolation from soil"
+    "title": "Leaching (pedology)"
    },
    {
     "description": "Bioleaching, the extraction of specific metals from their ores through the use of bacteria and fungi",
-    "title": "Bioleaching, the extraction of specific metals from their ores through the use of bacteria and fungi"
+    "title": "Bioleaching"
    },
    {
     "description": "Leachate, the liquid that drains or 'leaches' from a landfill",
-    "title": "Leachate, the liquid that drains or 'leaches' from a landfill"
+    "title": "Leachate"
    },
    {
     "description": "Leach (disambiguation)",
@@ -15973,4 +15973,4 @@
    "Zygophyllum fabago"
   ]
  }
-}
\ No newline at end of file
+}