Skip to content

Commit

Permalink
Add __init__() to template core module
Browse files Browse the repository at this point in the history
The template now recommends implementing an `__init__()` function that
allows the users to conveniently override the `astropy` configuration
system.
  • Loading branch information
eerovaher committed Mar 28, 2022
1 parent 5137807 commit 6a4027a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions astroquery/template_module/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@
@async_to_sync
class TemplateClass(BaseQuery):

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

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

@property
def _url(self):
Expand All @@ -56,6 +52,12 @@ def _url(self):
def _timeout(self):
return conf.timeout if self.timeout is None else self.timeout

"""
Not all the methods below are necessary but these cover most of the common
cases, new methods may be added if necessary, follow the guidelines at
<http://astroquery.readthedocs.io/en/latest/api.html>
"""

# all query methods are implemented with an "async" method that handles
# making the actual HTTP request and returns the raw HTTP response, which
# should be parsed by a separate _parse_result method. The query_object
Expand Down Expand Up @@ -332,7 +334,7 @@ def extract_image_urls(self, html_str):
pass


# the default tool for users to interact with is an instance of the Class
# the default tool for users to interact with is a default instance of the Class
Template = TemplateClass()

# once your class is done, tests should be written
Expand Down

0 comments on commit 6a4027a

Please sign in to comment.