Fix my.config handling during mypy

This commit is contained in:
Dima Gerasimov 2020-05-04 19:48:20 +01:00 committed by karlicoss
parent 1f07e1a2a8
commit fe763c3c04
5 changed files with 26 additions and 2 deletions

View file

@ -59,6 +59,16 @@ This is less convenient, but gives you more control.
The benefit of this way is that you get a bit more control, explicitly allowing your scripts to use your data. The benefit of this way is that you get a bit more control, explicitly allowing your scripts to use your data.
** optional packages
You can also install some opional packages
: pip3 install 'HPI[optional]'
They aren't necessary, but improve your experience. At the moment these are:
- [[https://github.com/karlicoss/cachew][cachew]]: automatic caching library, which can greatly speedup data access
- [[https://github.com/metachris/logzero][logzero]]: a nice logging library, supporting colors
* Setting up the modules * Setting up the modules
This is an *optional step* as some modules might work without extra setup. This is an *optional step* as some modules might work without extra setup.
But it depends on the specific module. But it depends on the specific module.

10
lint
View file

@ -60,12 +60,20 @@ def pylint():
def mypy(thing: str): def mypy(thing: str):
my_config_stub = DIR / 'mycfg_template'; assert my_config_stub.is_dir(), my_config_stub
env = {**os.environ}
MP = 'MYPYPATH'
if CI: # patch up, because CI doesn't have config... meh, but does the trick for now
mypypath = env.get(MP, None)
mypypath = str(my_config_stub) + ('' if mypypath is None else ':' + str(mypypath))
env[MP] = mypypath
is_package = Path(thing).suffix != '.py' is_package = Path(thing).suffix != '.py'
return run([ return run([
'mypy', 'mypy',
'--color-output', # TODO eh? doesn't work.. '--color-output', # TODO eh? doesn't work..
*(['-p'] if is_package else []), thing, *(['-p'] if is_package else []), thing,
], stdout=PIPE, stderr=PIPE) ], stdout=PIPE, stderr=PIPE, env=env)
def mypy_all() -> Iterable[Exception]: def mypy_all() -> Iterable[Exception]:

View file

@ -1,4 +1,5 @@
[mypy] [mypy]
# TODO ugh. I might need to set it dynamically because of macos??
mypy_path=~/.config/my mypy_path=~/.config/my
pretty = True pretty = True
show_error_context = True show_error_context = True

View file

@ -51,6 +51,11 @@ def main():
'pylint', 'pylint',
'mypy', 'mypy',
], ],
'optional': [
# TODO document these?
'logzero',
'cachew',
]
}, },
) )

View file

@ -30,7 +30,7 @@ commands = ./demo.py
[testenv:mypy] [testenv:mypy]
skip_install = true skip_install = true
commands = commands =
pip install -e .[testing] pip install -e .[testing] .[optional]
./lint ./lint