general: get rid of example_config & use demo/stub my.config instead
This commit is contained in:
parent
96be32aa51
commit
1849a66f08
10 changed files with 27 additions and 34 deletions
|
@ -1 +0,0 @@
|
|||
/tmp/my_demo/hypothesis_repo
|
|
@ -1,6 +1,15 @@
|
|||
"""
|
||||
Feel free to remove this if you don't need it/add your own custom settings and use them
|
||||
"""
|
||||
'''
|
||||
See https://github.com/karlicoss/HPI/blob/master/doc/SETUP.org#setting-up-modules for info on creating your own config
|
||||
|
||||
This file is used for:
|
||||
- documentation (as an example of the config structure)
|
||||
- mypy: this file provides some type annotations
|
||||
- for loading the actual user config
|
||||
'''
|
||||
#### vvvv you won't need this VVV in your personal config
|
||||
from my.core import init
|
||||
###
|
||||
|
||||
|
||||
from my.core import Paths, PathIsh
|
||||
|
||||
|
@ -44,7 +53,7 @@ class location:
|
|||
home: Union[LatLon, Sequence[Tuple[DateIsh, LatLon]]] = (1.0, -1.0)
|
||||
|
||||
|
||||
# todo hmm it's getting out of hand.. perhaps better to keep stubs in the actual my.config presetn in the repository instead
|
||||
class time:
|
||||
class tz:
|
||||
pass
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# TODO ok, this thing should trigger .cfg import presumably??
|
||||
from ..core import init
|
||||
|
||||
# TODO maybe, reuse example_config here?
|
||||
|
||||
class stub:
|
||||
key = 'value'
|
|
@ -21,12 +21,9 @@ def modules() -> Iterable[HPIModule]:
|
|||
|
||||
def ignored(m: str) -> bool:
|
||||
excluded = [
|
||||
# legacy stuff left for backwards compatibility
|
||||
'core.*',
|
||||
'config.*',
|
||||
## todo move these to core
|
||||
'kython.*',
|
||||
'mycfg_stub',
|
||||
##
|
||||
]
|
||||
exs = '|'.join(excluded)
|
||||
return re.match(f'^my.({exs})$', m) is not None
|
||||
|
|
5
mypy.ini
5
mypy.ini
|
@ -1,11 +1,12 @@
|
|||
[mypy]
|
||||
# TODO ugh. I might need to set it dynamically because of macos??
|
||||
mypy_path=~/.config/my
|
||||
pretty = True
|
||||
show_error_context = True
|
||||
show_error_codes = True
|
||||
check_untyped_defs = True
|
||||
namespace_packages = True
|
||||
# TODO ok, maybe it wasn't such a good idea..
|
||||
# mainly because then tox picks it up and running against the user config, not the repository config
|
||||
# mypy_path=~/.config/my
|
||||
|
||||
# it's not controlled by me, so for now just ignore..
|
||||
[mypy-my.config.repos.pdfannots.pdfannots]
|
||||
|
|
6
setup.py
6
setup.py
|
@ -32,12 +32,6 @@ def main():
|
|||
# for mypy
|
||||
'py.typed',
|
||||
],
|
||||
# todo not sure if need py.typed for all subpackages??
|
||||
'my.config': [
|
||||
'repos/.gitkeep',
|
||||
# TODO meh, get rid of this. If I remove, hypothesis tests (messing with config) might break though
|
||||
# not sure why it's not reproducing locally underr tox
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ def test_dynamic_configuration(notes: Path) -> None:
|
|||
import pytest # type: ignore
|
||||
|
||||
|
||||
def test_set_repo(tmp_path: Path) -> None:
|
||||
# TODO doublt I need it anymore.. keeping for now just for the sake of demonstration
|
||||
def _test_set_repo(tmp_path: Path) -> None:
|
||||
from my.cfg import config
|
||||
class user_config:
|
||||
export_path = 'whatever',
|
||||
|
|
17
tox.ini
17
tox.ini
|
@ -10,9 +10,6 @@ setenv = MY_CONFIG = nonexistent
|
|||
commands =
|
||||
pip install -e .[testing]
|
||||
# python -m pytest {posargs}
|
||||
# todo these are probably not necessary anymore?
|
||||
python3 -c 'from my.config import stub as config; print(config.key)'
|
||||
python3 -c 'import my.config; import my.config.repos' # shouldn't fail at least
|
||||
|
||||
# my.location.google deps
|
||||
pip install geopy ijson
|
||||
|
@ -27,7 +24,6 @@ commands =
|
|||
tests/core.py \
|
||||
tests/misc.py \
|
||||
tests/get_files.py \
|
||||
tests/config.py::test_set_repo \
|
||||
tests/config.py::test_environment_variable \
|
||||
tests/demo.py \
|
||||
tests/bluemaestro.py \
|
||||
|
@ -46,10 +42,8 @@ commands = ./demo.py
|
|||
|
||||
# specific modules that are known to be mypy compliant (to avoid false negatives)
|
||||
[testenv:mypy-modules]
|
||||
# todo add a stub with all the various configs for mypy/doc
|
||||
setenv = MYPYPATH=doc/example_config
|
||||
whitelist_externals = bash
|
||||
commands =
|
||||
# TODO ugh. somehow, user installed (editable??) packages leak into this environment??
|
||||
pip install -e .[testing] .[optional]
|
||||
pip install git+https://github.com/karlicoss/ghexport
|
||||
pip install git+https://github.com/karlicoss/hypexport
|
||||
|
@ -60,7 +54,12 @@ commands =
|
|||
|
||||
pip install git+https://github.com/karlicoss/porg
|
||||
|
||||
# todo I guess use a script...
|
||||
# ugh fuck. soo... need to reset HOME, otherwise user's site-packages are somehow leaking into mypy's path...
|
||||
# see https://github.com/python/mypy/blob/f6fb60ef69738cbfe2dfe56c747eca8f03735d8e/mypy/modulefinder.py#L487
|
||||
# this is particularly annoying when user's config is leaking and mypy isn't running against the repository config
|
||||
# maybe this issue... https://github.com/tox-dev/tox/issues/838
|
||||
# and also since it's Tox, we can't just set an env variable for a single command, have to spawn a subshell. jeez.
|
||||
bash -c 'HOME= \
|
||||
python3 -m mypy -p my.github.ghexport \
|
||||
-p my.hypothesis \
|
||||
-p my.instapaper \
|
||||
|
@ -75,7 +74,7 @@ commands =
|
|||
-p my.calendar.holidays \
|
||||
--txt-report .mypy-coverage \
|
||||
--html-report .mypy-coverage \
|
||||
{posargs}
|
||||
{posargs}'
|
||||
# txt report is a bit more convenient to view on CI
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue