1818from functools import cached_property
1919from hashlib import shake_128
2020from pathlib import Path
21- from typing import Literal , get_args
21+ from typing import Any , Literal , get_args
2222from urllib .parse import urlparse
2323
2424import charm_refresh
@@ -277,7 +277,7 @@ class PostgresqlOperatorCharm(TypedCharmBase[CharmConfig]):
277277
278278 # Override data_models.py TypedCharmBase config
279279 @cached_property
280- def config (self ):
280+ def config (self ) -> CharmConfig :
281281 """Return a config instance validated and parsed using the provided pydantic class."""
282282 config = {
283283 # Prefer value of option name with dash (-) and fallback to name with underscore (_)
@@ -286,7 +286,7 @@ def config(self):
286286 )
287287 for config_option in self .config_type .keys () # noqa: SIM118
288288 }
289- config = {
289+ config : dict [ str , Any ] = {
290290 config_option : value for config_option , value in config .items () if value is not None
291291 }
292292 return self .config_type (** config )
@@ -2853,7 +2853,7 @@ def generate_user_hash(self) -> str:
28532853 @cached_property
28542854 def generate_config_hash (self ) -> str :
28552855 """Generate current configuration hash."""
2856- return shake_128 (str (self .config .dict ()).encode ()).hexdigest (16 )
2856+ return shake_128 (str (self .config .model_dump ()).encode ()).hexdigest (16 )
28572857
28582858 def override_patroni_restart_condition (
28592859 self , new_condition : str , repeat_cause : str | None
0 commit comments