From 6a4027a69139f1653c83a21293cd20d306685fd0 Mon Sep 17 00:00:00 2001 From: Eero Vaher Date: Mon, 28 Mar 2022 20:18:02 +0200 Subject: [PATCH] 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. --- astroquery/template_module/core.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/astroquery/template_module/core.py b/astroquery/template_module/core.py index 907f34725c..56a54d39ff 100644 --- a/astroquery/template_module/core.py +++ b/astroquery/template_module/core.py @@ -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 - - """ + 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): @@ -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 + + """ + # 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 @@ -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