Hacker Newsnew | past | comments | ask | show | jobs | submit | jabwork's commentslogin

Configargparse is a great drop in replacement for argparse that I use to handle bridging env vars with cli flags

https://pypi.org/project/ConfigArgParse/


YES I need this in my life! Tried searching for such a thing but I guess had the wrong keywords.


Have you used pythons cffi and if so how would you differentiate this from that?

Does this work for all revisions of C? iirc cffi works for all of c89 and most of c99


No, but I used the equivalent in Lua. I was under the impression that no solution handled preprocessor macros, but this thread corrected me. I might do a follow-up post on this.


I ran into this same issue with python/SQLAlchemy. It's a connection pool thing


I spent two years using and then administering two RT servers.

I arrived with effectively no real PERL knowledge but a high level of Linux sysadmin competency

I hugely enjoyed working with the system. It was productive, flexible, and never gave me unexplained errors.

Even scripting on the perl api was an excellent experience.

Moreover the devs were extremely helpful in their irc channel (circa 2014-2016 at least) and walked me through a manual upgrade caused by the previous admin customizing the database schema in an unsafe way

Would highly recommend


For those of you using argparse I recommend looking at configargparse. A drop in replacement which adds environment variable support (similar to click) and config file support


I've wrestled with this problem several times. My conclusion was mocks are just fine, but this is a wart in that there isn't "one way to do it"

For the most part I can get by with one rule: always mock the module.

  with mock.patch('os.listdir'):
will always work, even if it doesn't accomplish what you want.

  with mock.patch('mymodule.os.listdir')
will fail if that module does not explicitly import os and instead does something like from os import listdir (perhaps because a later dev did not realize importing os directly was actually a requirement for the test and changed the code).

The rule is not perfect though. In the above case, the error will actually be

  ImportError: No module named os
This can be fixed with e.g.,

  assert hasattr(module, 'os'), "os module is not explicitly imported"
as a preamble to your test but ... it is not perfect by any means.

EDIT: formatting


I don't understand what you mean by "will always work, even if it doesn't accomplish what you want." Mocking os.listdir will be useless if your product code's imports don't match it. How is this "one rule" to use?


The os module ships with python, so the function call mocking os.listdir will always succeed even if the code being tested does not use os.listdir

By mocking mymodule.os.listdir you add a requirement that mymodule actually import the os module and take advantage of mock.patch failing loudly if it does not.


For the OPs context (their kids) I expect they'll have a lot of typing too do on school computers


Even Apple had the famous episode of releasing an update that bricked phones with replacement parts that weren't sanctioned. They reversed it after much public outcry.

For less common hardware the situation is just as bad. Agriculture equipment has been a pain point for many to get repaired, as the parts are much harder to find and the limited number of certified repair shops can be pressured to stop servicing equipment deemed end of life by the manufacturer


Drat,I had hoped for another edition of this https://www.litepc.com/

For the uninitiated this basically cranked your ability to uninstall windows components up to 11, allowing you to strip out IE and and get windows humming along quite well on antiquated hardware.


I've never had problems with this when requirements.txt contains package versions

Have you, or are you not using explicit versions supplied by eg pip freeze?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: