Mirror of https://github.com/roostorg/osprey github.com/roostorg/osprey
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: migrate Dict and List to native types in config files (#103)

authored by

Rashmi Raghunandan and committed by
GitHub
510980f5 5c1f999c

+11 -12
+3 -4
osprey_worker/src/osprey/engine/stdlib/configs/labels_config.py
··· 1 1 from enum import Enum 2 - from typing import Dict, List 3 2 4 3 from pydantic import BaseModel, root_validator 5 4 ··· 25 24 26 25 27 26 class LabelInfo(BaseModel): 28 - valid_for: List[str] = [] 27 + valid_for: list[str] = [] 29 28 connotation: LabelConnotation = LabelConnotation.NEUTRAL 30 29 description: str = '' 31 30 ··· 35 34 36 35 @register_config_subkey(LABELS_CONFIG_SUBKEY) 37 36 class LabelsConfig(BaseModel): 38 - labels: Dict[str, LabelInfo] 37 + labels: dict[str, LabelInfo] 39 38 40 39 @root_validator(pre=True) 41 - def root_validator(cls, values: object) -> Dict[str, object]: 40 + def root_validator(cls, values: object) -> dict[str, object]: 42 41 # Remove old values so we can be backward compatible during the deploy 43 42 # TODO - Remove this once the new config handling is fully deployed 44 43 assert isinstance(values, dict)
+8 -8
osprey_worker/src/osprey/worker/ui_api/osprey/views/config.py
··· 1 - from typing import Any, Dict, List, Set 1 + from typing import Any 2 2 3 3 import typing_inspect 4 4 from flask import Blueprint ··· 22 22 """Contains everything in the base ui config, as well as additional fields that are relevant 23 23 to configuring the UI""" 24 24 25 - feature_name_to_entity_type_mapping: Dict[str, str] 26 - feature_name_to_value_type_mapping: Dict[str, str] 27 - label_info_mapping: Dict[str, LabelInfo] 28 - known_feature_locations: List[FeatureLocation] 29 - known_action_names: Set[str] 25 + feature_name_to_entity_type_mapping: dict[str, str] 26 + feature_name_to_value_type_mapping: dict[str, str] 27 + label_info_mapping: dict[str, LabelInfo] 28 + known_feature_locations: list[FeatureLocation] 29 + known_action_names: set[str] 30 30 current_user: User 31 - rule_info_mapping: Dict[str, str] 31 + rule_info_mapping: dict[str, str] 32 32 33 33 34 34 _SIMPLE_TYPE_CONVERTIBLE = {str, int, bool, float} ··· 59 59 raise AssertionError(f"Don't know how to serialize {to_display_str(t)}") 60 60 61 61 62 - def _get_feature_name_to_value_type_mapping(engine: OspreyEngine) -> Dict[str, str]: 62 + def _get_feature_name_to_value_type_mapping(engine: OspreyEngine) -> dict[str, str]: 63 63 return { 64 64 name: _serialize_type_for_ui(t) 65 65 for name, t in engine.get_post_execution_feature_name_to_value_type_mapping().items()