diff --git a/doc/example_config/my/config/repos/.gitkeep b/doc/example_config/my/config/repos/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/doc/example_config/my/config/repos/hypexport b/doc/example_config/my/config/repos/hypexport deleted file mode 120000 index 0fbfff27..00000000 --- a/doc/example_config/my/config/repos/hypexport +++ /dev/null @@ -1 +0,0 @@ -/tmp/my_demo/hypothesis_repo \ No newline at end of file diff --git a/doc/example_config/my/config/__init__.py b/my/config.py similarity index 74% rename from doc/example_config/my/config/__init__.py rename to my/config.py index 55101a89..a336cf5d 100644 --- a/doc/example_config/my/config/__init__.py +++ b/my/config.py @@ -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 + diff --git a/my/config/__init__.py b/my/config/__init__.py deleted file mode 100644 index 735cc9ed..00000000 --- a/my/config/__init__.py +++ /dev/null @@ -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' diff --git a/my/config/repos/.gitkeep b/my/config/repos/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/my/core/util.py b/my/core/util.py index f730d5b8..f9a5e726 100644 --- a/my/core/util.py +++ b/my/core/util.py @@ -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 diff --git a/mypy.ini b/mypy.ini index c1ab5d6b..ea34c127 100644 --- a/mypy.ini +++ b/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] diff --git a/setup.py b/setup.py index 377bc1c5..fbc152d3 100644 --- a/setup.py +++ b/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 - ], }, diff --git a/tests/config.py b/tests/config.py index 5078ce0b..6e365175 100644 --- a/tests/config.py +++ b/tests/config.py @@ -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', diff --git a/tox.ini b/tox.ini index 542187cd..9d20a777 100644 --- a/tox.ini +++ b/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