misc: get rid of SimpleNamespace uses
This commit is contained in:
parent
2a9fd54c12
commit
c0bbb4eaf2
2 changed files with 11 additions and 16 deletions
|
@ -7,10 +7,9 @@ Usage:
|
|||
|
||||
After that, you can set config attributes:
|
||||
|
||||
from types import SimpleNamespace
|
||||
config.twitter = SimpleNamespace(
|
||||
export_path='/path/to/twitter/exports',
|
||||
)
|
||||
class user_config:
|
||||
export_path = '/path/to/twitter/exports'
|
||||
config.twitter = user_config
|
||||
"""
|
||||
# todo why do we bring this into scope? don't remember..
|
||||
import my.config as config
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
from pathlib import Path
|
||||
|
||||
|
||||
# TODO switch these from using SimpleNamespace
|
||||
|
||||
def setup_notes_path(notes: Path) -> None:
|
||||
# TODO reuse doc from my.cfg?
|
||||
from my.cfg import config
|
||||
|
||||
from types import SimpleNamespace
|
||||
config.orgmode = SimpleNamespace( # type: ignore[misc,assignment]
|
||||
roots=[notes],
|
||||
)
|
||||
class user_config:
|
||||
roots = [notes]
|
||||
config.orgmode = user_config # type: ignore[misc,assignment]
|
||||
# TODO FIXME ugh. this belongs to tz provider or global config or someting
|
||||
import pytz
|
||||
config.weight = SimpleNamespace( # type: ignore[misc,assignment]
|
||||
class user_config_2:
|
||||
default_timezone = pytz.timezone('Europe/London')
|
||||
)
|
||||
config.weight = user_config_2 # type: ignore[misc,assignment]
|
||||
|
||||
|
||||
def test_dynamic_configuration(notes: Path) -> None:
|
||||
|
@ -38,10 +35,9 @@ import pytest # type: ignore
|
|||
|
||||
def test_set_repo(tmp_path: Path) -> None:
|
||||
from my.cfg import config
|
||||
from types import SimpleNamespace
|
||||
config.hypothesis = SimpleNamespace( # type: ignore[misc,assignment]
|
||||
export_path='whatever',
|
||||
)
|
||||
class user_config:
|
||||
export_path = 'whatever',
|
||||
config.hypothesis = user_config # type: ignore[misc,assignment]
|
||||
|
||||
# precondition:
|
||||
# should fail because can't find hypexport
|
||||
|
|
Loading…
Add table
Reference in a new issue