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