Repository: gmarmstrong/python-datamuse (language: python)

Issue:
Remove `WORD_PARAMS` and `SUGGEST_PARAMS`.
The list of parameters in `WORD_PARAMS` and `SUGGEST_PARAMS` are unnecessary since the Datamuse API ignores parameters it does not recognize anyway. Therefore, the argument check `Datamuse._validate_args` is superfluous. Thoughts, @gmarmstrong ?


Discussion / hints:
PR #8 removes the `SUGGEST_PARAMS`.

Fix patch:
diff --git a/README.md b/README.md
index d31d9c7..2d56ccd 100644
--- a/README.md
+++ b/README.md
@@ -8,22 +8,23 @@ install this library with `pip3 install python-datamuse`.
 
 ## Changelog
 
-### Version 1.3.0
+### Version 1.3.* (2019-09-20)
 
 - Add optional arguments to `suggest` method
+- Document and test suggestion method
+- **(1.3.1):** Update README example
+- **(1.3.1):** Remove WORD_PARAMS
+- **(1.3.1):** Document `words` method
 
-### Version 1.2.1
-
-- Fix README formatting on PyPI
-
-### Version 1.2.0
+### Version 1.2.* (2018-10-23)
 
 - Raise Python version to 3.6
 - Mock the Datamuse API for tests
 - Restructure project files
 - Set README as PyPI long description
+- **(1.2.1):** Fix README formatting on PyPI
 
-### Version 1.1.0
+### Version 1.1.0 (2018-02-18)
 
 - Changed to Python 3
 - Uploaded to PyPI, added instructions for PyPI installation
@@ -35,19 +36,15 @@ install this library with `pip3 install python-datamuse`.
 ## Example
 
 ```python
->>> from datamuse import datamuse
+>>> import datamuse
 >>> api = datamuse.Datamuse()
->>> ninth_rhymes = api.words(rel_rhy='ninth', max=5)
->>> ninth_rhymes
+>>> api.words(rel_rhy='ninth', max=5)  # words that rhyme with "ninth"
 []
->>> orange_rhymes = api.words(rel_rhy='orange', max=5)
->>> orange_rhymes
+>>> api.words(rel_rhy='orange', max=5)  # words that rhyme with "orange"
 [{'word': 'door hinge', 'score': 74, 'numSyllables': 2}]
->>> yellow_things = api.words(rel_jja='yellow', max=5)
->>> yellow_things
+>>> api.words(rel_jja='yellow', max=5)  # things often described as "yellow"
 [{'word': 'fever', 'score': 1001}, {'word': 'color', 'score': 1000}, {'word': 'flowers', 'score': 999}, {'word': 'light', 'score': 998}, {'word': 'colour', 'score': 997}]
->>> foo_complete = api.suggest(s='foo', max=10)
->>> foo_complete
+>>> api.suggest(s='foo', max_results=10)  # completion suggestions for "foo"
 [{'word': 'food', 'score': 3888}, {'word': 'foot', 'score': 3041}, {'word': 'fool', 'score': 1836}, {'word': 'football', 'score': 1424}, {'word': 'footage', 'score': 1328}, {'word': 'footprint', 'score': 1082}, {'word': 'foolish', 'score': 967}, {'word': 'foof', 'score': 930}, {'word': 'footing', 'score': 786}, {'word': 'foolproof', 'score': 697}]
 ```
 
diff --git a/datamuse/datamuse.py b/datamuse/datamuse.py
index 0f20769..06d7adc 100755
--- a/datamuse/datamuse.py
+++ b/datamuse/datamuse.py
@@ -2,34 +2,6 @@
 
 import requests
 
-WORD_PARAMS = [
-    'ml',
-    'sl',
-    'sp',
-    'rel_jja',
-    'rel_jjb',
-    'rel_syn',
-    'rel_trg',
-    'rel_ant',
-    'rel_spc',
-    'rel_gen',
-    'rel_com',
-    'rel_par',
-    'rel_bga',
-    'rel_bgb',
-    'rel_rhy',
-    'rel_nry',
-    'rel_hom',
-    'rel_cns',
-    'v',
-    'topics',
-    'lc',
-    'rc',
-    'max',
-    'md',
-    'qe'
-]
-
 
 class Datamuse(object):
 
@@ -46,13 +18,6 @@ def _validate_max(max_results):
         if not (0 < max_results <= 1000):
             raise ValueError("Datamuse only supports values of max in (0, 1000]")
 
-    def _validate_args(self, args, param_set):
-        for arg in args:
-            if arg not in param_set:
-                raise ValueError('{0} is not a valid parameter for this endpoint.'.format(arg))
-            if arg == 'max':
-                self._validate_max(args[arg])
-
     def _get_resource(self, endpoint, **kwargs):
         url = '/'.join([self.api_root, endpoint])
         response = requests.get(url, params=kwargs)
@@ -63,8 +28,16 @@ def set_max_default(self, max_results):
         self.max = max_results
 
     def words(self, **kwargs):
-        """https://www.datamuse.com/api/"""
-        self._validate_args(kwargs, WORD_PARAMS)
+        """
+        This endpoint returns a list of words (and multiword expressions) from
+        a given vocabulary that match a given set of constraints.
+
+        See <https://www.datamuse.com/api/> for the official Datamuse API
+        documentation for the `/words` endpoint.
+
+        :param `**kwargs`: Query parameters of constraints and hints.
+        :return: A list of words matching that match the given constraints.
+        """
         if 'max' not in kwargs:
             kwargs.update({'max': self.max})
         return self._get_resource('words', **kwargs)
diff --git a/setup.py b/setup.py
index 0b189ec..2469012 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@
 
 setup(
     name="python-datamuse",
-    version="1.3.0",
+    version="1.3.1",
     keywords="datamuse, linguistics, language, wrapper",
     packages=["datamuse"],
     url="https://github.com/gmarmstrong/python-datamuse",


Test patch:
diff --git a/tests/datamuse/test_api.py b/tests/datamuse/test_api.py
index e02ad40..6e31b1f 100755
--- a/tests/datamuse/test_api.py
+++ b/tests/datamuse/test_api.py
@@ -66,11 +66,6 @@ def test_near_rhymes(self):
         self.assertTrue(len(data) <= self.max)
         print("near rhyme", data)
 
-    def test_bad_request(self):
-        args = {'foo': 42}
-        with self.assertRaises(ValueError):
-            self.api.words(**args)
-
     def test_set_max(self):
         self.assertTrue(self.api.max, 100)
         self.api.set_max_default(10)