Skip to content

Commit 6a4027a

Browse files
committed
Add __init__() to template core module
The template now recommends implementing an `__init__()` function that allows the users to conveniently override the `astropy` configuration system.
1 parent 5137807 commit 6a4027a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

astroquery/template_module/core.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,13 @@
3636
@async_to_sync
3737
class TemplateClass(BaseQuery):
3838

39-
"""
40-
Not all the methods below are necessary but these cover most of the common
41-
cases, new methods may be added if necessary, follow the guidelines at
42-
<http://astroquery.readthedocs.io/en/latest/api.html>
43-
"""
39+
def __init__(self, url='', timeout=None):
40+
self.url = url # A falsy default that cannot be mistaken for a valid value.
41+
self.timeout = timeout # Use `None` as default if the falsy value could be valid.
4442

4543
# The private properties defined here allow the users to change the
4644
# configuration values at runtime, or to completely override them with
4745
# instance attributes.
48-
url = '' # A falsy default that cannot be mistaken for a valid value.
49-
timeout = None # Use `None` if the falsy value could be valid.
5046

5147
@property
5248
def _url(self):
@@ -56,6 +52,12 @@ def _url(self):
5652
def _timeout(self):
5753
return conf.timeout if self.timeout is None else self.timeout
5854

55+
"""
56+
Not all the methods below are necessary but these cover most of the common
57+
cases, new methods may be added if necessary, follow the guidelines at
58+
<http://astroquery.readthedocs.io/en/latest/api.html>
59+
"""
60+
5961
# all query methods are implemented with an "async" method that handles
6062
# making the actual HTTP request and returns the raw HTTP response, which
6163
# should be parsed by a separate _parse_result method. The query_object
@@ -332,7 +334,7 @@ def extract_image_urls(self, html_str):
332334
pass
333335

334336

335-
# the default tool for users to interact with is an instance of the Class
337+
# the default tool for users to interact with is a default instance of the Class
336338
Template = TemplateClass()
337339

338340
# once your class is done, tests should be written

0 commit comments

Comments
 (0)