diff --git a/jwql/website/apps/jwql/forms.py b/jwql/website/apps/jwql/forms.py index f9ce45b7b..90c43cafe 100644 --- a/jwql/website/apps/jwql/forms.py +++ b/jwql/website/apps/jwql/forms.py @@ -160,7 +160,7 @@ class JwqlQueryForm(BaseForm): num_choices = [(50, 50), (100, 100), (200, 200), (500, 500)] num_per_page = forms.ChoiceField( required=True, - choices=num_choices, initial=num_choices[1], + choices=num_choices, initial=num_choices[3], widget=forms.RadioSelect) # instrument specific parameters diff --git a/jwql/website/apps/jwql/views.py b/jwql/website/apps/jwql/views.py index 54cb17859..cb4c31782 100644 --- a/jwql/website/apps/jwql/views.py +++ b/jwql/website/apps/jwql/views.py @@ -131,6 +131,7 @@ def jwql_query(request): parameters[QueryConfigKeys.DATE_RANGE] = form.cleaned_data['date_range'] parameters[QueryConfigKeys.PROPOSAL_CATEGORY] = form.cleaned_data['proposal_category'] parameters[QueryConfigKeys.SORT_TYPE] = form.cleaned_data['sort_type'] + parameters[QueryConfigKeys.NUM_PER_PAGE] = form.cleaned_data['num_per_page'] parameters[QueryConfigKeys.ANOMALIES] = all_anomalies parameters[QueryConfigKeys.APERTURES] = all_apers parameters[QueryConfigKeys.FILTERS] = all_filters diff --git a/style_guide/example.py b/style_guide/example.py index 47db3b3a0..d145529de 100644 --- a/style_guide/example.py +++ b/style_guide/example.py @@ -73,7 +73,7 @@ # Global variables should be avoided, but if used should be named with # all-caps -A_GLOBAL_VARIABLE = 'foo' # type: str +A_GLOBAL_VARIABLE = "foo" # type: str @log_fail @@ -92,14 +92,14 @@ def my_main_function(path: str, filter: str) -> None: The filter to process (e.g. "F606W"). """ - logging.info('Using {} as an input file'.format(path)) + logging.info("Using {} as an input file".format(path)) an_int = 1 # type: int a_float = 3.14 # type: float a_bool = True # type: bool - a_list = ['Dog', 'Cat', 'Turtle', False, 7] # type: List[Union[str, bool, int]] - a_tuple = ('Dog', 'Cat', 'Turtle', False, 7) # type: Tuple[str, str, str, bool, int] - a_dict = {'key1': 'value1', 'key2': 'value2'} # type: Dict[str, str] + a_list = ["Dog", "Cat", "Turtle", False, 7] # type: List[Union[str, bool, int]] + a_tuple = ("Dog", "Cat", "Turtle", False, 7) # type: Tuple[str, str, str, bool, int] + a_dict = {"key1": "value1", "key2": "value2"} # type: Dict[str, str] an_obj = object() # type: object result = some_other_function(an_int, a_float, a_bool, a_list, a_tuple, a_dict, an_obj) # type: Optional[int] @@ -117,21 +117,13 @@ def parse_args() -> argparse.Namespace: """ # Create help strings - path_help = 'The path to the input file.' # type: str + path_help = "The path to the input file." # type: str filter_help = 'The filter to process (e.g. "F606W").' # type: str # Add arguments parser = argparse.ArgumentParser() # type: argparse.ArgumentParser - parser.add_argument('path', - type=str, - default=os.getcwd(), - help=path_help) - parser.add_argument('-f --filter', - dest='filter', - type=str, - required=False, - default='F606W', - help=filter_help) + parser.add_argument("path", type=str, default=os.getcwd(), help=path_help) + parser.add_argument("-f --filter", dest="filter", type=str, required=False, default="F606W", help=filter_help) # Parse args args = parser.parse_args() # type: argparse.Namespace @@ -140,8 +132,7 @@ def parse_args() -> argparse.Namespace: @log_timing -def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[Any], - a_tuple: Tuple[Any], a_dict: Dict[Any, Any], an_obj: object) -> int: +def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[Any], a_tuple: Tuple[Any], a_dict: Dict[Any, Any], an_obj: object) -> int: """This function just does a bunch of nonsense. But it serves as a decent example of some things. @@ -170,8 +161,8 @@ def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[ """ # File I/O should be handeled with 'with open' when possible - with open('my_file', 'w') as f: - f.write('My favorite integer is {}'.format(an_int)) + with open("my_file", "w") as f: + f.write("My favorite integer is {}".format(an_int)) # Operators should be separated by spaces logging.info(a_float + a_float) @@ -179,10 +170,9 @@ def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[ return an_int -if __name__ == '__main__': - +if __name__ == "__main__": # Configure logging - module = os.path.basename(__file__).strip('.py') + module = os.path.basename(__file__).strip(".py") configure_logging(module) args = parse_args() # type: argparse.Namespace diff --git a/style_guide/typing_demo/typing_demo_1.py b/style_guide/typing_demo/typing_demo_1.py index 33c11e397..ad4bc30d0 100644 --- a/style_guide/typing_demo/typing_demo_1.py +++ b/style_guide/typing_demo/typing_demo_1.py @@ -7,8 +7,7 @@ """ import sys -from typing import (List, Set, Dict, Tuple, Union, Optional, Callable, - Iterable, Any) +from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Union assert sys.version_info >= (3, 6) # PEP 526 added variable annotations @@ -18,7 +17,7 @@ a_string: str = "jwql" a_list: List[int] = [1] a_set: Set[int] = {1, 2, 3} -a_dict: Dict[str, bool] = {'jwql': True} # Have to specify both keys and values +a_dict: Dict[str, bool] = {"jwql": True} # Have to specify both keys and values # For python versions prior to 3.6, the variable annotation syntax uses comments: # annotated_variable = 1 # type: int @@ -68,6 +67,7 @@ def a_generator() -> Iterable[int]: # Type annotations are stored in __annotations__, either as a local variable # or as an object attribute. + def print_annotations(arg: Any) -> bool: if not hasattr(arg, "__annotations__"): print("Sorry, that argument doesn't have its own __annotations__.") @@ -76,8 +76,7 @@ def print_annotations(arg: Any) -> bool: return bool(arg.__annotations__) -for name in ["an_integer", "a_generic_function", "two_arg_function", - "func_alias", "anon_func", "a_generator"]: +for name in ["an_integer", "a_generic_function", "two_arg_function", "func_alias", "anon_func", "a_generator"]: var = locals()[name] print(f"Annotations for {name}:") if not print_annotations(var):