We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
TheGuardianCredentials returns wrong valid property
##### Text version
0.3.0
##### Orange version
3.14
##### Expected behavior
``` python
credentials = TheGuardianCredentials('<your-api-key>')
print(credentials.valid)
```
Should correctly return if key is valid

##### Actual behavior
If the given key exceeds the API limit `credentials.valid` still returns True



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `orangecontrib/text/guardian.py`
Content:
```
1 """ This module fetches data from The Guardian API.
2 
3 To use first create :class:`TheGuardianCredentials`:
4 
5     >>> from orangecontrib.text.guardian import TheGuardianCredentials
6     >>> credentials = TheGuardianCredentials('<your-api-key>')
7 
8 Then create :class:`TheGuardianAPI` object and use it for searching:
9 
10     >>> from orangecontrib.text.guardian import TheGuardianAPI
11     >>> api = TheGuardianAPI(credentials)
12     >>> corpus = api.search('Slovenia', max_documents=10)
13     >>> len(corpus)
14     10
15 
16 """
17 
18 import requests
19 import math
20 import json
21 import os
22 
23 from Orange import data
24 
25 from orangecontrib.text.corpus import Corpus
26 
27 
28 BASE_URL = 'http://content.guardianapis.com/search'
29 ARTICLES_PER_PAGE = 10
30 
31 
32 class TheGuardianCredentials:
33     """ The Guardian API credentials. """
34     def __init__(self, key):
35         """
36         Args:
37             key (str): The Guardian API key. Use `test` for testing purposes.
38         """
39         self.key = key
40 
41     @property
42     def valid(self):
43         """ Check if given API key is valid. """
44         response = requests.get(BASE_URL, {'api-key': self.key})
45         return response.status_code != 403      # 403 == Forbidden
46 
47     def __eq__(self, other):
48         return self.key == other.key
49 
50 
51 class TheGuardianAPI:
52     attributes = []
53 
54     class_vars = [
55         (data.DiscreteVariable('Section'), lambda doc: doc['sectionName']),
56     ]
57 
58     tv = data.TimeVariable('Publication Date')
59     metas = [
60         (data.StringVariable('Headline'), lambda doc: doc['fields']['headline']),
61         (data.StringVariable('Content'), lambda doc: doc['fields']['bodyText']),
62         (data.StringVariable('Trail Text'), lambda doc: doc['fields']['trailText']),
63         (data.StringVariable('HTML'), lambda doc: doc['fields']['body']),
64         (tv, lambda doc: TheGuardianAPI.tv.parse(doc['webPublicationDate'])),
65         (data.DiscreteVariable('Type'), lambda doc: doc['type']),
66         (data.DiscreteVariable('Language'), lambda doc: doc['fields']['lang']),
67         (data.StringVariable('Tags'),
68             lambda doc: ', '.join(tag['webTitle'] for tag in doc['tags'])),
69         (data.StringVariable('URL'), lambda doc: doc['webUrl']),
70         (data.ContinuousVariable('Word Count', number_of_decimals=0),
71             lambda doc: doc['fields']['wordcount']),
72     ]
73 
74     text_features = [metas[0][0], metas[1][0]]  # Headline + Content
75     title_indices = [-1]    # Headline
76 
77     def __init__(self, credentials, on_progress=None, should_break=None):
78         """
79         Args:
80             credentials (:class:`TheGuardianCredentials`): The Guardian Creentials.
81             on_progress (callable): Function for progress reporting.
82             should_break (callable): Function for early stopping.
83         """
84         self.per_page = ARTICLES_PER_PAGE
85         self.pages = 0
86         self.credentials = credentials
87         self.on_progress = on_progress or (lambda x, y: None)
88         self.should_break = should_break or (lambda: False)
89 
90         self.results = []
91 
92     def _search(self, query, from_date, to_date, page=1):
93         data = self._build_query(query, from_date, to_date, page)
94 
95         response = requests.get(BASE_URL, data)
96         parsed = json.loads(response.text)
97 
98         if page == 1:   # store number of pages
99             self.pages = parsed['response']['pages']
100 
101         self.results.extend(parsed['response']['results'])
102 
103     def _build_query(self, query, from_date=None, to_date=None, page=1):
104         data = {
105             'q': query,
106             'api-key': self.credentials.key,
107             'page': str(page),
108             'show-fields': 'headline,trailText,body,bodyText,lang,wordcount',
109             'show-tags': 'all',
110         }
111         if from_date is not None:
112             data['from-date'] = from_date
113         if to_date is not None:
114             data['to-date'] = to_date
115 
116         return data
117 
118     def search(self, query, from_date=None, to_date=None, max_documents=None,
119                accumulate=False):
120         """
121         Search The Guardian API for articles.
122 
123         Args:
124             query (str): A query for searching the articles by
125             from_date (str): Search only articles newer than the date provided.
126                 Date should be in ISO format; e.g. '2016-12-31'.
127             to_date (str): Search only articles older than the date provided.
128                 Date should be in ISO format; e.g. '2016-12-31'.
129             max_documents (int): Maximum number of documents to retrieve.
130                 When not given, retrieve all documents.
131             accumulate (bool): A flag indicating whether to accumulate results
132                 of multiple consequent search calls.
133 
134         Returns:
135             :ref:`Corpus`
136         """
137         if not accumulate:
138             self.results = []
139 
140         self._search(query, from_date, to_date)
141 
142         pages = math.ceil(max_documents/self.per_page) if max_documents else self.pages
143         self.on_progress(self.per_page, pages * self.per_page)
144 
145         for p in range(2, pages+1):     # to one based
146             if self.should_break():
147                 break
148             self._search(query, from_date, to_date, p)
149             self.on_progress(p*self.per_page, pages * self.per_page)
150 
151         c = Corpus.from_documents(
152             self.results, 'The Guardian', self.attributes, self.class_vars,
153             self.metas, title_indices=self.title_indices)
154         c.text_features = self.text_features
155         return c
156 
157 
158 if __name__ == '__main__':
159     key = os.getenv('THE_GUARDIAN_API_KEY', 'test')
160     credentials = TheGuardianCredentials(key)
161     print(credentials.valid)
162     api = TheGuardianAPI(credentials=credentials)
163     c = api.search('refugees', max_documents=10)
164     print(c)
165
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/orangecontrib/text/guardian.py b/orangecontrib/text/guardian.py
--- a/orangecontrib/text/guardian.py
+++ b/orangecontrib/text/guardian.py
@@ -42,7 +42,7 @@
     def valid(self):
         """ Check if given API key is valid. """
         response = requests.get(BASE_URL, {'api-key': self.key})
-        return response.status_code != 403      # 403 == Forbidden
+        return response.status_code == 200
 
     def __eq__(self, other):
         return self.key == other.key

{"golden_diff": "diff --git a/orangecontrib/text/guardian.py b/orangecontrib/text/guardian.py\n--- a/orangecontrib/text/guardian.py\n+++ b/orangecontrib/text/guardian.py\n@@ -42,7 +42,7 @@\n     def valid(self):\n         \"\"\" Check if given API key is valid. \"\"\"\n         response = requests.get(BASE_URL, {'api-key': self.key})\n-        return response.status_code != 403      # 403 == Forbidden\n+        return response.status_code == 200\n \n     def __eq__(self, other):\n         return self.key == other.key\n", "issue": "TheGuardianCredentials returns wrong valid property\n##### Text version\r\n0.3.0\r\n##### Orange version\r\n3.14\r\n##### Expected behavior\r\n``` python\r\ncredentials = TheGuardianCredentials('<your-api-key>')\r\nprint(credentials.valid)\r\n```\r\nShould correctly return if key is valid\r\n\r\n##### Actual behavior\r\nIf the given key exceeds the API limit `credentials.valid` still returns True\r\n\r\n\n", "before_files": [{"content": "\"\"\" This module fetches data from The Guardian API.\n\nTo use first create :class:`TheGuardianCredentials`:\n\n    >>> from orangecontrib.text.guardian import TheGuardianCredentials\n    >>> credentials = TheGuardianCredentials('<your-api-key>')\n\nThen create :class:`TheGuardianAPI` object and use it for searching:\n\n    >>> from orangecontrib.text.guardian import TheGuardianAPI\n    >>> api = TheGuardianAPI(credentials)\n    >>> corpus = api.search('Slovenia', max_documents=10)\n    >>> len(corpus)\n    10\n\n\"\"\"\n\nimport requests\nimport math\nimport json\nimport os\n\nfrom Orange import data\n\nfrom orangecontrib.text.corpus import Corpus\n\n\nBASE_URL = 'http://content.guardianapis.com/search'\nARTICLES_PER_PAGE = 10\n\n\nclass TheGuardianCredentials:\n    \"\"\" The Guardian API credentials. \"\"\"\n    def __init__(self, key):\n        \"\"\"\n        Args:\n            key (str): The Guardian API key. Use `test` for testing purposes.\n        \"\"\"\n        self.key = key\n\n    @property\n    def valid(self):\n        \"\"\" Check if given API key is valid. \"\"\"\n        response = requests.get(BASE_URL, {'api-key': self.key})\n        return response.status_code != 403      # 403 == Forbidden\n\n    def __eq__(self, other):\n        return self.key == other.key\n\n\nclass TheGuardianAPI:\n    attributes = []\n\n    class_vars = [\n        (data.DiscreteVariable('Section'), lambda doc: doc['sectionName']),\n    ]\n\n    tv = data.TimeVariable('Publication Date')\n    metas = [\n        (data.StringVariable('Headline'), lambda doc: doc['fields']['headline']),\n        (data.StringVariable('Content'), lambda doc: doc['fields']['bodyText']),\n        (data.StringVariable('Trail Text'), lambda doc: doc['fields']['trailText']),\n        (data.StringVariable('HTML'), lambda doc: doc['fields']['body']),\n        (tv, lambda doc: TheGuardianAPI.tv.parse(doc['webPublicationDate'])),\n        (data.DiscreteVariable('Type'), lambda doc: doc['type']),\n        (data.DiscreteVariable('Language'), lambda doc: doc['fields']['lang']),\n        (data.StringVariable('Tags'),\n            lambda doc: ', '.join(tag['webTitle'] for tag in doc['tags'])),\n        (data.StringVariable('URL'), lambda doc: doc['webUrl']),\n        (data.ContinuousVariable('Word Count', number_of_decimals=0),\n            lambda doc: doc['fields']['wordcount']),\n    ]\n\n    text_features = [metas[0][0], metas[1][0]]  # Headline + Content\n    title_indices = [-1]    # Headline\n\n    def __init__(self, credentials, on_progress=None, should_break=None):\n        \"\"\"\n        Args:\n            credentials (:class:`TheGuardianCredentials`): The Guardian Creentials.\n            on_progress (callable): Function for progress reporting.\n            should_break (callable): Function for early stopping.\n        \"\"\"\n        self.per_page = ARTICLES_PER_PAGE\n        self.pages = 0\n        self.credentials = credentials\n        self.on_progress = on_progress or (lambda x, y: None)\n        self.should_break = should_break or (lambda: False)\n\n        self.results = []\n\n    def _search(self, query, from_date, to_date, page=1):\n        data = self._build_query(query, from_date, to_date, page)\n\n        response = requests.get(BASE_URL, data)\n        parsed = json.loads(response.text)\n\n        if page == 1:   # store number of pages\n            self.pages = parsed['response']['pages']\n\n        self.results.extend(parsed['response']['results'])\n\n    def _build_query(self, query, from_date=None, to_date=None, page=1):\n        data = {\n            'q': query,\n            'api-key': self.credentials.key,\n            'page': str(page),\n            'show-fields': 'headline,trailText,body,bodyText,lang,wordcount',\n            'show-tags': 'all',\n        }\n        if from_date is not None:\n            data['from-date'] = from_date\n        if to_date is not None:\n            data['to-date'] = to_date\n\n        return data\n\n    def search(self, query, from_date=None, to_date=None, max_documents=None,\n               accumulate=False):\n        \"\"\"\n        Search The Guardian API for articles.\n\n        Args:\n            query (str): A query for searching the articles by\n            from_date (str): Search only articles newer than the date provided.\n                Date should be in ISO format; e.g. '2016-12-31'.\n            to_date (str): Search only articles older than the date provided.\n                Date should be in ISO format; e.g. '2016-12-31'.\n            max_documents (int): Maximum number of documents to retrieve.\n                When not given, retrieve all documents.\n            accumulate (bool): A flag indicating whether to accumulate results\n                of multiple consequent search calls.\n\n        Returns:\n            :ref:`Corpus`\n        \"\"\"\n        if not accumulate:\n            self.results = []\n\n        self._search(query, from_date, to_date)\n\n        pages = math.ceil(max_documents/self.per_page) if max_documents else self.pages\n        self.on_progress(self.per_page, pages * self.per_page)\n\n        for p in range(2, pages+1):     # to one based\n            if self.should_break():\n                break\n            self._search(query, from_date, to_date, p)\n            self.on_progress(p*self.per_page, pages * self.per_page)\n\n        c = Corpus.from_documents(\n            self.results, 'The Guardian', self.attributes, self.class_vars,\n            self.metas, title_indices=self.title_indices)\n        c.text_features = self.text_features\n        return c\n\n\nif __name__ == '__main__':\n    key = os.getenv('THE_GUARDIAN_API_KEY', 'test')\n    credentials = TheGuardianCredentials(key)\n    print(credentials.valid)\n    api = TheGuardianAPI(credentials=credentials)\n    c = api.search('refugees', max_documents=10)\n    print(c)\n", "path": "orangecontrib/text/guardian.py"}], "after_files": [{"content": "\"\"\" This module fetches data from The Guardian API.\n\nTo use first create :class:`TheGuardianCredentials`:\n\n    >>> from orangecontrib.text.guardian import TheGuardianCredentials\n    >>> credentials = TheGuardianCredentials('<your-api-key>')\n\nThen create :class:`TheGuardianAPI` object and use it for searching:\n\n    >>> from orangecontrib.text.guardian import TheGuardianAPI\n    >>> api = TheGuardianAPI(credentials)\n    >>> corpus = api.search('Slovenia', max_documents=10)\n    >>> len(corpus)\n    10\n\n\"\"\"\n\nimport requests\nimport math\nimport json\nimport os\n\nfrom Orange import data\n\nfrom orangecontrib.text.corpus import Corpus\n\n\nBASE_URL = 'http://content.guardianapis.com/search'\nARTICLES_PER_PAGE = 10\n\n\nclass TheGuardianCredentials:\n    \"\"\" The Guardian API credentials. \"\"\"\n    def __init__(self, key):\n        \"\"\"\n        Args:\n            key (str): The Guardian API key. Use `test` for testing purposes.\n        \"\"\"\n        self.key = key\n\n    @property\n    def valid(self):\n        \"\"\" Check if given API key is valid. \"\"\"\n        response = requests.get(BASE_URL, {'api-key': self.key})\n        return response.status_code == 200\n\n    def __eq__(self, other):\n        return self.key == other.key\n\n\nclass TheGuardianAPI:\n    attributes = []\n\n    class_vars = [\n        (data.DiscreteVariable('Section'), lambda doc: doc['sectionName']),\n    ]\n\n    tv = data.TimeVariable('Publication Date')\n    metas = [\n        (data.StringVariable('Headline'), lambda doc: doc['fields']['headline']),\n        (data.StringVariable('Content'), lambda doc: doc['fields']['bodyText']),\n        (data.StringVariable('Trail Text'), lambda doc: doc['fields']['trailText']),\n        (data.StringVariable('HTML'), lambda doc: doc['fields']['body']),\n        (tv, lambda doc: TheGuardianAPI.tv.parse(doc['webPublicationDate'])),\n        (data.DiscreteVariable('Type'), lambda doc: doc['type']),\n        (data.DiscreteVariable('Language'), lambda doc: doc['fields']['lang']),\n        (data.StringVariable('Tags'),\n            lambda doc: ', '.join(tag['webTitle'] for tag in doc['tags'])),\n        (data.StringVariable('URL'), lambda doc: doc['webUrl']),\n        (data.ContinuousVariable('Word Count', number_of_decimals=0),\n            lambda doc: doc['fields']['wordcount']),\n    ]\n\n    text_features = [metas[0][0], metas[1][0]]  # Headline + Content\n    title_indices = [-1]    # Headline\n\n    def __init__(self, credentials, on_progress=None, should_break=None):\n        \"\"\"\n        Args:\n            credentials (:class:`TheGuardianCredentials`): The Guardian Creentials.\n            on_progress (callable): Function for progress reporting.\n            should_break (callable): Function for early stopping.\n        \"\"\"\n        self.per_page = ARTICLES_PER_PAGE\n        self.pages = 0\n        self.credentials = credentials\n        self.on_progress = on_progress or (lambda x, y: None)\n        self.should_break = should_break or (lambda: False)\n\n        self.results = []\n\n    def _search(self, query, from_date, to_date, page=1):\n        data = self._build_query(query, from_date, to_date, page)\n\n        response = requests.get(BASE_URL, data)\n        parsed = json.loads(response.text)\n\n        if page == 1:   # store number of pages\n            self.pages = parsed['response']['pages']\n\n        self.results.extend(parsed['response']['results'])\n\n    def _build_query(self, query, from_date=None, to_date=None, page=1):\n        data = {\n            'q': query,\n            'api-key': self.credentials.key,\n            'page': str(page),\n            'show-fields': 'headline,trailText,body,bodyText,lang,wordcount',\n            'show-tags': 'all',\n        }\n        if from_date is not None:\n            data['from-date'] = from_date\n        if to_date is not None:\n            data['to-date'] = to_date\n\n        return data\n\n    def search(self, query, from_date=None, to_date=None, max_documents=None,\n               accumulate=False):\n        \"\"\"\n        Search The Guardian API for articles.\n\n        Args:\n            query (str): A query for searching the articles by\n            from_date (str): Search only articles newer than the date provided.\n                Date should be in ISO format; e.g. '2016-12-31'.\n            to_date (str): Search only articles older than the date provided.\n                Date should be in ISO format; e.g. '2016-12-31'.\n            max_documents (int): Maximum number of documents to retrieve.\n                When not given, retrieve all documents.\n            accumulate (bool): A flag indicating whether to accumulate results\n                of multiple consequent search calls.\n\n        Returns:\n            :ref:`Corpus`\n        \"\"\"\n        if not accumulate:\n            self.results = []\n\n        self._search(query, from_date, to_date)\n\n        pages = math.ceil(max_documents/self.per_page) if max_documents else self.pages\n        self.on_progress(self.per_page, pages * self.per_page)\n\n        for p in range(2, pages+1):     # to one based\n            if self.should_break():\n                break\n            self._search(query, from_date, to_date, p)\n            self.on_progress(p*self.per_page, pages * self.per_page)\n\n        c = Corpus.from_documents(\n            self.results, 'The Guardian', self.attributes, self.class_vars,\n            self.metas, title_indices=self.title_indices)\n        c.text_features = self.text_features\n        return c\n\n\nif __name__ == '__main__':\n    key = os.getenv('THE_GUARDIAN_API_KEY', 'test')\n    credentials = TheGuardianCredentials(key)\n    print(credentials.valid)\n    api = TheGuardianAPI(credentials=credentials)\n    c = api.search('refugees', max_documents=10)\n    print(c)\n", "path": "orangecontrib/text/guardian.py"}]}