profile
viewpoint
Brendon Smith br3ndonland Intellia Therapeutics Boston, MA https://br3ndonland.github.io I build software to support the creation, curation, and application of scientific knowledge.

br3ndonland/udacity-fsnd 51

Udacity Full Stack Web Developer Nanodegree program (FSND) course materials

br3ndonland/inboard 3

🚢 Docker images to power your Python APIs and help you ship faster. With support for Uvicorn, Gunicorn, Starlette, and FastAPI.

br3ndonland/br3ndonland 2

GitHub profile repo :muscle: :nerd_face: :coffee:

br3ndonland/template-python 2

Template repository for Python projects

br3ndonland/algorithms 1

Miscellaneous curiosities from the world of computer programming

br3ndonland/cite 1

Resources for citing and managing journal articles

br3ndonland/el2bl 1

Migrate your notes from Evernote to Bear, retaining note links

br3ndonland/full-stack-fastapi-postgresql 1

Cookiecutter application generator using Python FastAPI, Vue.js, PostgreSQL, Docker, and more

br3ndonland/homebrew-brewfile 1

Packages and applications I use

br3ndonland/R-guide 1

A quick reference guide and sample code for statistical programming in R

PR closed theskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

theskumar/python-dotenv#164 was closed, but I still find the behavior of load_dotenv() confusing.

The load_dotenv() function is supposed to "Parse a .env file and then load all the variables found as environment variables," according to its docstring. However, the function always returns True, even if no .env file is found or no environment variables are set, because of DotEnv.set_as_environment_variables().

@theskumar commented in theskumar/python-dotenv#164:

The return value of load_dotenv is undocumented as I was planning to do something useful with it, but could not settle down to one.

I think it make sense to return proper return based on if file was found or not, but if the idea is to just stop execution if no .env is found I think it would make much more sense to just pass it a fail_silently=False and have it raise an exception.

Rather than adding fail_silently=False, which is very similar to verbose=True, I think the easiest way to move forward on this is to update the behavior of verbose=True. This PR will improve load_dotenv(verbose=True) in the following ways:

  • Improve DotEnv.set_as_environment_variables() to log a message and return False when no variables are loaded and verbose=True. It will still return True as usual if verbose=False. logger.info() is used for consistency with theskumar/python-dotenv#245, although I think a warning would be clearer.
  • Add test_load_dotenv_empty_file() with tests for verbose=True and verbose=False.
  • Update test_load_dotenv_no_file_verbose() to handle the new LookupError exception.

Flake8, Pytest, and Tox (only tried Python 2.7 and 3.7) are currently passing on my branch.

+36 -6

9 comments

2 changed files

br3ndonland

pr closed time in 4 hours

pull request commenttheskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

The maintainer was unwilling to implement the breaking change proposed by this PR.

br3ndonland

comment created time in 4 hours

Pull request review commenttheskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

 def _is_interactive():   def load_dotenv(dotenv_path=None, stream=None, verbose=False, override=False, interpolate=True, **kwargs):-    # type: (Union[Text, _PathLike, None], Optional[_StringIO], bool, bool, bool, Union[None, Text]) -> bool+    # type: (Optional[Union[Text, _PathLike, _StringIO]], Optional[_StringIO], bool, bool, bool, Optional[Text]) -> bool     """Parse a .env file and then load all the variables found as environment variables.      - *dotenv_path*: absolute or relative path to .env file.     - *stream*: `StringIO` object with .env content.-    - *verbose*: whether to output the warnings related to missing .env file etc. Defaults to `False`.+    - *verbose*: whether to output log messages related to loading .env files etc. Defaults to `False`.     - *override*: where to override the system environment variables with the variables in `.env` file.                   Defaults to `False`.     """-    f = dotenv_path or stream or find_dotenv()-    return DotEnv(f, verbose=verbose, interpolate=interpolate, **kwargs).set_as_environment_variables(override=override)+    f = find_dotenv(filename=str(dotenv_path)) or stream or find_dotenv()

the use case I had in mind was the following, where load_dotenv(".env") is called in sub.py but the .env is absent in sub_project

If the user:

  • Has a file at project/.env, but doesn't want to load it
  • Doesn't have a file at sub_project/.env, but wants to load it
  • Runs load_dotenv(".env") in sub.py, expecting to load the non-existent file

That sounds like a situation in which they should be notified of the problem, either with an exception or logger warning. Instead of providing an exception or logger warning, load_dotenv simply returns True. I find this behavior misleading, which was the reason I opened the PR originally.

In this case, however, I'm not convinced it's worth changing the behavior, at least for now. I don't think saving 2 or 3 lines of code is enough to justify it.

The goal of this PR was to change the return behavior of load_dotenv. If you're not willing to consider a change, there's nothing further to discuss.

br3ndonland

comment created time in 4 hours

PullRequestReviewEvent

push eventbr3ndonland/br3ndonland

Brendon Smith

commit sha bc2239b07747f4527de9ce5d64aade11f7f5a939

:pencil: Separate personal and work PGP keys https://keybase.io/br3ndonland https://shields.io/category/social The default Keybase badge provided by shields.io doesn't allow specification of the PGP key, so it just shows the first key on the user's profile. I have two keys, one for personal use and one for work, so I would like to show them separately.

view details

push time in 9 hours

startedHypothesisWorks/hypothesis

started time in 9 hours

startedspotify/luigi

started time in 9 hours

startedSecureAuthCorp/impacket

started time in 9 hours

startedpyenv/pyenv

started time in 9 hours

startedSecureAuthCorp/impacket

started time in 9 hours

starteduiri/toml

started time in 9 hours

startedtheskumar/python-dotenv

started time in 9 hours

startedshosca/django-rest-witchcraft

started time in 9 hours

startedencode/django-rest-framework

started time in 9 hours

startedtheskumar/python-dotenv

started time in 9 hours

Pull request review commenttheskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

 def _is_interactive():   def load_dotenv(dotenv_path=None, stream=None, verbose=False, override=False, interpolate=True, **kwargs):-    # type: (Union[Text, _PathLike, None], Optional[_StringIO], bool, bool, bool, Union[None, Text]) -> bool+    # type: (Optional[Union[Text, _PathLike, _StringIO]], Optional[_StringIO], bool, bool, bool, Optional[Text]) -> bool     """Parse a .env file and then load all the variables found as environment variables.      - *dotenv_path*: absolute or relative path to .env file.     - *stream*: `StringIO` object with .env content.-    - *verbose*: whether to output the warnings related to missing .env file etc. Defaults to `False`.+    - *verbose*: whether to output log messages related to loading .env files etc. Defaults to `False`.     - *override*: where to override the system environment variables with the variables in `.env` file.                   Defaults to `False`.     """-    f = dotenv_path or stream or find_dotenv()-    return DotEnv(f, verbose=verbose, interpolate=interpolate, **kwargs).set_as_environment_variables(override=override)+    f = find_dotenv(filename=str(dotenv_path)) or stream or find_dotenv()

The other advantage to using find_dotenv() here is that it becomes easier to manage the return value of load_dotenv. If the user runs load_dotenv(".does_not_exist"), f = dotenv_path will evaluate to f = ".does_not_exist", but f = find_dotenv(".does_not_exist") will evaluate to f = "", same as the third option in the conditional expression (find_dotenv()).

br3ndonland

comment created time in 9 hours

PullRequestReviewEvent

Pull request review commenttheskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

 def _is_interactive():   def load_dotenv(dotenv_path=None, stream=None, verbose=False, override=False, interpolate=True, **kwargs):-    # type: (Union[Text, _PathLike, None], Optional[_StringIO], bool, bool, bool, Union[None, Text]) -> bool+    # type: (Optional[Union[Text, _PathLike, _StringIO]], Optional[_StringIO], bool, bool, bool, Optional[Text]) -> bool     """Parse a .env file and then load all the variables found as environment variables.      - *dotenv_path*: absolute or relative path to .env file.     - *stream*: `StringIO` object with .env content.-    - *verbose*: whether to output the warnings related to missing .env file etc. Defaults to `False`.+    - *verbose*: whether to output log messages related to loading .env files etc. Defaults to `False`.     - *override*: where to override the system environment variables with the variables in `.env` file.                   Defaults to `False`.     """-    f = dotenv_path or stream or find_dotenv()-    return DotEnv(f, verbose=verbose, interpolate=interpolate, **kwargs).set_as_environment_variables(override=override)+    f = find_dotenv(filename=str(dotenv_path)) or stream or find_dotenv()

I think find_dotenv(filename=".env") stops walking up the directories when it finds the file, right? Given a directory structure like this (adapted from the prepare_file_hierarchy test in test_main.py):


project_root
└── src
    ├── package1
    │   ├── package1_child1
    │   │   └── package1_child2
    │   └── .env
    └── package2
        ├── package2_child1
        │   └── package2_child2
        └── .env

If find_dotenv(".env") is run from one of the child directories in package2, it will stop when it finds package2/.env. Is this correct?

br3ndonland

comment created time in 9 hours

PullRequestReviewEvent

Pull request review commenttheskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

 def _is_interactive():   def load_dotenv(dotenv_path=None, stream=None, verbose=False, override=False, interpolate=True, **kwargs):-    # type: (Union[Text, _PathLike, None], Optional[_StringIO], bool, bool, bool, Union[None, Text]) -> bool+    # type: (Optional[Union[Text, _PathLike, _StringIO]], Optional[_StringIO], bool, bool, bool, Optional[Text]) -> bool

Update: I restored the previous docstring to match the master branch. Looks like it's passing now.

br3ndonland

comment created time in 9 hours

PullRequestReviewEvent

push eventbr3ndonland/python-dotenv

Brendon Smith

commit sha 19f8a6d864b732aa2f4b54f42c4d4cd1d3b3d7cf

Use arrange-act-assert syntax in new tests theskumar/python-dotenv#164 theskumar/python-dotenv#245 theskumar/python-dotenv#263 https://github.com/theskumar/python-dotenv/pull/263#discussion_r511040069

view details

Brendon Smith

commit sha 78c783531fc7f18234785554def5374e9f4cb7a2

Restore previous load_dotenv type comment theskumar/python-dotenv#164 theskumar/python-dotenv#245 theskumar/python-dotenv#263 https://github.com/theskumar/python-dotenv/pull/263#discussion_r511497039

view details

push time in 9 hours

Pull request review commenttheskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

 def _is_interactive():   def load_dotenv(dotenv_path=None, stream=None, verbose=False, override=False, interpolate=True, **kwargs):-    # type: (Union[Text, _PathLike, None], Optional[_StringIO], bool, bool, bool, Union[None, Text]) -> bool+    # type: (Optional[Union[Text, _PathLike, _StringIO]], Optional[_StringIO], bool, bool, bool, Optional[Text]) -> bool

What Python version were you using? The error in Travis CI occurred with Python 3.6.7, and I was able to reproduce it locally. In order to reproduce the error, you need create a Python 3.6.7 virtualenv (I used pyenv and pyenv-virtualenv), and run tox within that virtualenv.

br3ndonland

comment created time in 9 hours

PullRequestReviewEvent

startedSecureAuthCorp/impacket

started time in a day

push eventbr3ndonland/algorithms

Brendon Smith

commit sha ce67877296e8f4e075eea69b217ece05727ce930

Add string case conversion algorithms - PascalCase - snake_case - PascalCase to snake_case

view details

Brendon Smith

commit sha 67869a03ce0a829fe1c9d9cd02c2c340083fff7e

Update pyproject.toml for Poetry 1.1

view details

Brendon Smith

commit sha 6938ef3ea581c89703dcbbe709f8b421f2dce7e8

Include py.typed in pyproject.toml https://www.python.org/dev/peps/pep-0561/ https://mypy.readthedocs.io/en/latest/installed_packages.html br3ndonland/inboard@d5f030f br3ndonland/algorithms@001a869 The py.typed file indicates that this package supplies type information.

view details

Brendon Smith

commit sha ff87d6acfbe0d5bbb925a9b4da41307433b8b6c5

Use iterdir instead of glob in paths.py I was seeing some inconsistency with `Path(".").glob("**/*.py")`. It wasn't always picking up all the Python modules in a directory. If recursion into subdirectories is not needed, `Path(".").iterdir()` is a simpler alternative.

view details

Brendon Smith

commit sha 91bce0191e643446faf6d0eec49d62bf42e3d319

Add tests for paths.py br3ndonland/algorithms@8f0970f

view details

Brendon Smith

commit sha f9573f1a7ee66042edd9f1e5b518c73eb5de556e

Update dependencies .venv ❯ poetry update Package operations: 0 installs, 9 updates, 0 removals • Updating attrs (19.3.0 -> 20.2.0) • Updating cfgv (3.1.0 -> 3.2.0) • Updating identify (1.4.24 -> 1.5.6) • Updating iniconfig (1.0.1 -> 1.1.1) • Updating nodeenv (1.4.0 -> 1.5.0) • Updating regex (2020.10.15 -> 2020.10.23) • Updating typing-extensions (3.7.4.2 -> 3.7.4.3) • Updating virtualenv (20.0.27 -> 20.0.35) • Updating isort (5.6.1 -> 5.6.4) .venv ❯ pre-commit autoupdate Updating https://github.com/pycqa/isort ... updating 5.6.2 -> 5.6.4. Updating https://github.com/pre-commit/pre-commit-hooks ... updating v3.2.0 -> v3.3.0.

view details

Brendon Smith

commit sha 90a6a788e694b855641a27887cb5b92fb8fec6f5

Add TOML parsing methods br3ndonland/inboard@1773bfd

view details

push time in a day

push eventbr3ndonland/algorithms

Brendon Smith

commit sha f604129d3a7c1317fb27f4f2ba6a884788262fae

Add algorithms for converting string case - PascalCase - snake_case - PascalCase to snake_case

view details

Brendon Smith

commit sha df654baf64def1e871d4eca6bc37ac248fb792aa

Update pyproject.toml for Poetry 1.1

view details

Brendon Smith

commit sha 005f5354917c2c63c46e201d49ae010917ddbe0a

Include py.typed in pyproject.toml https://www.python.org/dev/peps/pep-0561/ https://mypy.readthedocs.io/en/latest/installed_packages.html br3ndonland/inboard@d5f030f br3ndonland/algorithms@001a869 The py.typed file indicates that this package supplies type information.

view details

Brendon Smith

commit sha c2d6e1dc2f34b16bdcbfa3e416460f32b14fb00c

Use iterdir instead of glob in paths.py I was seeing some inconsistency with `Path(".").glob("**/*.py")`. It wasn't always picking up all the Python modules in a directory. If recursion into subdirectories is not needed, `Path(".").iterdir()` is a simpler alternative.

view details

Brendon Smith

commit sha 0f10ba5ba4bef3b30a2d0f42959069adccd16b91

Add tests for paths.py br3ndonland/algorithms@8f0970f

view details

Brendon Smith

commit sha 4f1ccf29c74b15e9d30faedfc7450ca6844c4313

Update dependencies .venv ❯ poetry update Package operations: 0 installs, 9 updates, 0 removals • Updating attrs (19.3.0 -> 20.2.0) • Updating cfgv (3.1.0 -> 3.2.0) • Updating identify (1.4.24 -> 1.5.6) • Updating iniconfig (1.0.1 -> 1.1.1) • Updating nodeenv (1.4.0 -> 1.5.0) • Updating regex (2020.10.15 -> 2020.10.23) • Updating typing-extensions (3.7.4.2 -> 3.7.4.3) • Updating virtualenv (20.0.27 -> 20.0.35) • Updating isort (5.6.1 -> 5.6.4) .venv ❯ pre-commit autoupdate Updating https://github.com/pycqa/isort ... updating 5.6.2 -> 5.6.4. Updating https://github.com/pre-commit/pre-commit-hooks ... updating v3.2.0 -> v3.3.0.

view details

Brendon Smith

commit sha 344f3e44cf9bfc017d6a0fcc62f92aae031d8619

Add TOML parsing methods br3ndonland/inboard@1773bfd

view details

push time in a day

Pull request review commenttheskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

 def _is_interactive():   def load_dotenv(dotenv_path=None, stream=None, verbose=False, override=False, interpolate=True, **kwargs):-    # type: (Union[Text, _PathLike, None], Optional[_StringIO], bool, bool, bool, Union[None, Text]) -> bool+    # type: (Optional[Union[Text, _PathLike, _StringIO]], Optional[_StringIO], bool, bool, bool, Optional[Text]) -> bool     """Parse a .env file and then load all the variables found as environment variables.      - *dotenv_path*: absolute or relative path to .env file.     - *stream*: `StringIO` object with .env content.-    - *verbose*: whether to output the warnings related to missing .env file etc. Defaults to `False`.+    - *verbose*: whether to output log messages related to loading .env files etc. Defaults to `False`.     - *override*: where to override the system environment variables with the variables in `.env` file.                   Defaults to `False`.     """-    f = dotenv_path or stream or find_dotenv()-    return DotEnv(f, verbose=verbose, interpolate=interpolate, **kwargs).set_as_environment_variables(override=override)+    f = find_dotenv(filename=str(dotenv_path)) or stream or find_dotenv()

Yes. Wouldn't that be the intended behavior? Do you envision a use case in which a user would run load_dotenv(".env"), but they wouldn't want to actually find the .env file?

br3ndonland

comment created time in a day

PullRequestReviewEvent

Pull request review commenttheskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

 def _is_interactive():   def load_dotenv(dotenv_path=None, stream=None, verbose=False, override=False, interpolate=True, **kwargs):-    # type: (Union[Text, _PathLike, None], Optional[_StringIO], bool, bool, bool, Union[None, Text]) -> bool+    # type: (Optional[Union[Text, _PathLike, _StringIO]], Optional[_StringIO], bool, bool, bool, Optional[Text]) -> bool

I had to add that in order to resolve the Travis CI failure shown here. If you have another suggestion, I'm happy to try it.

br3ndonland

comment created time in a day

PullRequestReviewEvent

Pull request review commenttheskumar/python-dotenv

Update load_dotenv to return False if no dotenv source is loaded

 def test_load_dotenv_existing_file(dotenv_file):     assert os.environ == {"a": "b"}  +@mock.patch.dict(os.environ, {}, clear=True)+def test_load_dotenv_existing_file_empty(dotenv_file):+    logger = logging.getLogger("dotenv.main")++    with mock.patch.object(logger, "info") as mock_info:+        assert dotenv.load_dotenv(dotenv_file) is True

Agreed. I updated the new tests to follow arrange-act-assert more closely.

br3ndonland

comment created time in a day

PullRequestReviewEvent

push eventbr3ndonland/python-dotenv

Brendon Smith

commit sha 48231dcd346d2d0b69089e8ff444422a76cfe878

Use act-arrange-assert syntax in new tests theskumar/python-dotenv#164 theskumar/python-dotenv#245 theskumar/python-dotenv#263 https://github.com/theskumar/python-dotenv/pull/263#discussion_r511040069

view details

push time in a day

push eventbr3ndonland/homebrew-brewfile

Brendon Smith

commit sha 9adfbfe56cc2f3f17156102e7b2a7f55c39621ed

Switch from Plex to Jellyfin https://jellyfin.org/ I've had a good run with Plex, but I'm ready to try something new. Plex was a convenient way to stream media from my macOS machine to my Roku, but there were many things I didn't like, including: - They were using a cross-site fingerprinter for a while in their Plex media server web app. I discovered this with the Brave browser. - It's difficult to find and configure privacy settings, and you get no privacy benefit for subscribing to a premium plan. - Batch-editing playlists is painful. You can't select and move a range of items, only one at a time. - Playlist import from Apple macOS Music/iTunes never worked well. - Selecting music to sync for offline listening is painful. There's no "sync only checked songs" option like there is in macOS Music. Conversions for offline syncing are slow. - Music metadata can't be edited as well as in macOS Music. - Remote access doesn't work well when the media server computer is on a VPN. The connection gets routed through the Plex relay servers, and quality is poor.

view details

Brendon Smith

commit sha 95369c7b2d4885154de76755025f1d6c07887a3a

Uninstall VSCode Insiders I'm using it less and less now. The proprietary Microsoft features aren't really that useful, and the fact that they make their marketplace proprietary, when the content is mostly provided for free by independent developers, is not cool. VSCodium has been great and I use it as my daily driver.

view details

Brendon Smith

commit sha 5271ede29e807e4e846d847f9d9b412fcf4c3877

Remove the Kraken br3ndonland/homebrew-brewfile@7ec200e Don't find it useful. The Git CLI and VSCode integrations work for me.

view details

Brendon Smith

commit sha bd1f385769a7df4f779c7fc5b2ec1dc5d8d459b6

Adjust Brewfile for work

view details

push time in a day

push eventbr3ndonland/homebrew-brewfile

Brendon Smith

commit sha 95369c7b2d4885154de76755025f1d6c07887a3a

Uninstall VSCode Insiders I'm using it less and less now. The proprietary Microsoft features aren't really that useful, and the fact that they make their marketplace proprietary, when the content is mostly provided for free by independent developers, is not cool. VSCodium has been great and I use it as my daily driver.

view details

Brendon Smith

commit sha 5271ede29e807e4e846d847f9d9b412fcf4c3877

Remove the Kraken br3ndonland/homebrew-brewfile@7ec200e Don't find it useful. The Git CLI and VSCode integrations work for me.

view details

push time in a day

push eventbr3ndonland/homebrew-brewfile

Brendon Smith

commit sha 9adfbfe56cc2f3f17156102e7b2a7f55c39621ed

Switch from Plex to Jellyfin https://jellyfin.org/ I've had a good run with Plex, but I'm ready to try something new. Plex was a convenient way to stream media from my macOS machine to my Roku, but there were many things I didn't like, including: - They were using a cross-site fingerprinter for a while in their Plex media server web app. I discovered this with the Brave browser. - It's difficult to find and configure privacy settings, and you get no privacy benefit for subscribing to a premium plan. - Batch-editing playlists is painful. You can't select and move a range of items, only one at a time. - Playlist import from Apple macOS Music/iTunes never worked well. - Selecting music to sync for offline listening is painful. There's no "sync only checked songs" option like there is in macOS Music. Conversions for offline syncing are slow. - Music metadata can't be edited as well as in macOS Music. - Remote access doesn't work well when the media server computer is on a VPN. The connection gets routed through the Plex relay servers, and quality is poor.

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 02ba5c4735954c94befab3ec1ab35956d04e4be8

Add pyenv to .zshrc https://github.com/pyenv/pyenv https://github.com/pyenv/pyenv-virtualenv Pyenv is used to install multiple Python versions on the system. The integration will be commented out by default to avoid slowing down shell load times.

view details

Brendon Smith

commit sha 16e6c115ef601cc5c28154ad63c87fe2e0b01b66

Increase VSCodium terminal scrollback Default is 1000. Not nearly enough for log output. Increase to 10000.

view details

Brendon Smith

commit sha a11cf9afe6e1d3bafa52631bd123d3ae277bd054

Update code-spell-checker words

view details

Brendon Smith

commit sha dbb0f58abb073ea606888e040b9f5fd5400e892a

Configure shellcheck for Zsh koalaman/shellcheck#809 - Add VSCodium shellcheck config - Retain Zsh shebang, but specify Bash for shellcheck, in .zshrc - Update .zshrc with shellcheck recommendations - Update shellcheck config in GitHub Actions workflow: GitHub Actions still throws SC1071 errors if --shell=bash is set, so --exclude=SC1071 must also be set.

view details

Brendon Smith

commit sha c9580d894fac87ca73039fe78329bf31e38c8e16

Adjust dotfiles for work

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha dbb0f58abb073ea606888e040b9f5fd5400e892a

Configure shellcheck for Zsh koalaman/shellcheck#809 - Add VSCodium shellcheck config - Retain Zsh shebang, but specify Bash for shellcheck, in .zshrc - Update .zshrc with shellcheck recommendations - Update shellcheck config in GitHub Actions workflow: GitHub Actions still throws SC1071 errors if --shell=bash is set, so --exclude=SC1071 must also be set.

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 473f0778216da9c8e0d215b711314dbb6ba8d6c5

Configure shellcheck for Zsh TODO: ref shellcheck issues - Add VSCodium shellcheck config - Retain Zsh shebang, but specify Bash for shellcheck, in .zshrc - Update .zshrc with shellcheck recommendations - Update shellcheck config in GitHub Actions workflow: GitHub Actions still throws SC1071 errors if --shell=bash is set, so --exclude=SC1071 must also be set.

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 1c738e870afbb1f0231d5318a301f962b354e078

WIP: Configure shellcheck for Zsh TODO: ref shellcheck issues - Add VSCodium shellcheck config - Update .zshrc with shellcheck recommendations - Update shellcheck config in GitHub Actions workflow

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha f5621840c36281fd551ed7c84f8a90048f754d6f

WIP: Configure shellcheck for Zsh TODO: ref shellcheck issues - Add VSCodium shellcheck config - Update .zshrc with shellcheck recommendations - Update shellcheck config in GitHub Actions workflow

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 1429b97a712e938be6027b4e47b9d1d9fea3e11a

WIP: Configure shellcheck for Zsh TODO: ref shellcheck issues - Add VSCodium shellcheck config - Update .zshrc with shellcheck recommendations - Update shellcheck config in GitHub Actions workflow

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 54ea34a4620d97e96f646d9e8f4d494843f66be5

WIP: Configure shellcheck for Zsh TODO: ref shellcheck issues - Add VSCodium shellcheck config - Update .zshrc with shellcheck recommendations - Update shellcheck config in GitHub Actions workflow

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 5b2652a9d3bb1408050799d3d1801e40093ef3e7

WIP: Configure shellcheck for Zsh TODO: ref shellcheck issues - Add VSCodium shellcheck config - Update .zshrc with shellcheck recommendations - Update shellcheck config in GitHub Actions workflow

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 77f4fe3c5392d05e5032ecfb6c5847f9306ebcaf

WIP: Configure shellcheck for Zsh TODO: ref shellcheck issues - Add VSCodium shellcheck config - Update .zshrc with shellcheck recommendations - Update shellcheck config in GitHub Actions workflow

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha bef662bd8bf1c5fc1fc18df12ee5ec877527ecf8

WIP: Configure shellcheck for Zsh TODO: ref shellcheck issues

view details

push time in a day

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 02ba5c4735954c94befab3ec1ab35956d04e4be8

Add pyenv to .zshrc https://github.com/pyenv/pyenv https://github.com/pyenv/pyenv-virtualenv Pyenv is used to install multiple Python versions on the system. The integration will be commented out by default to avoid slowing down shell load times.

view details

Brendon Smith

commit sha 16e6c115ef601cc5c28154ad63c87fe2e0b01b66

Increase VSCodium terminal scrollback Default is 1000. Not nearly enough for log output. Increase to 10000.

view details

Brendon Smith

commit sha a11cf9afe6e1d3bafa52631bd123d3ae277bd054

Update code-spell-checker words

view details

Brendon Smith

commit sha 2aed35a91c3eae4ac0e92b2229a47fb5bcdac509

WIP: Configure shellcheck for Zsh TODO: ref shellcheck issues

view details

push time in a day

push eventbr3ndonland/python-dotenv

Brendon Smith

commit sha 0aceda2305b06645a97f133aa32c1ed60ae63ef1

Re-simplify load_dotenv check for dotenv source theskumar/python-dotenv#164 theskumar/python-dotenv#245 theskumar/python-dotenv#263 theskumar/python-dotenv@33cf7f4 The syntax will now be closer to the original. The only change to f is the addition of find_dotenv() to check the dotenv_path. If find_dotenv can't find a dotenv source at dotenv_path, the conditional expression will move to the next or.

view details

push time in 2 days

startedultrajson/ultrajson

started time in 4 days

startedencode/django-rest-framework

started time in 4 days

startedshosca/django-rest-witchcraft

started time in 4 days

startedHypothesisWorks/hypothesis

started time in 4 days

startedpixie-labs/pixie

started time in 4 days

startedspotify/backstage

started time in 4 days

startedspotify/chartify

started time in 4 days

startedspotify/luigi

started time in 4 days

startedpyenv/pyenv

started time in 4 days

starteduiri/toml

started time in 4 days

startedencode/typesystem

started time in 4 days

startedencode/orm

started time in 4 days

startedencode/databases

started time in 4 days

startedencode/databases

started time in 4 days

startedencode/databases

started time in 4 days

startedHypothesisWorks/hypothesis

started time in 4 days

startedpixie-labs/pixie

started time in 5 days

startedspotify/backstage

started time in 5 days

startedspotify/chartify

started time in 5 days

startedspotify/backstage

started time in 5 days

startedpyenv/pyenv

started time in 5 days

starteduiri/toml

started time in 5 days

startedencode/typesystem

started time in 5 days

startedencode/orm

started time in 5 days

startedcharmbracelet/bubbletea

started time in 5 days

startedcharmbracelet/glow

started time in 5 days

startedxwmx/nb

started time in 5 days

startedgnab/remark

started time in 5 days

startedbeeware/podium

started time in 5 days

startedgithub/docs

started time in 5 days

startedantonbabenko/serverless.tf

started time in 5 days

startedantonbabenko/serverless.tf

started time in 5 days

startedcharmbracelet/bubbletea

started time in 5 days

startedcharmbracelet/glow

started time in 5 days

startedxwmx/nb

started time in 5 days

startedcharmbracelet/bubbletea

started time in 5 days

startedcharmbracelet/glow

started time in 5 days

startedspotify/chartify

started time in 5 days

startedspotify/luigi

started time in 5 days

startedspotify/backstage

started time in 5 days

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 5ae7eb5ba6b8714d52a9ceaab0e042e7e4c33c63

Add GitHub token setting to bootstrap.sh br3ndonland/dotfiles@4ebb0ce - Add `STRAP_GITHUB_TOKEN` variable - Read `STRAP_GITHUB_TOKEN` from environment (instead of Strap web app) - Provide a notification message if `STRAP_GITHUB_TOKEN` is not set, without setting a value (to allow `[ -n $STRAP_GITHUB_TOKEN ]`)

view details

Brendon Smith

commit sha e091613939ae71484dcfb5f304cae643f61db4a2

Add pyenv to .zshrc

view details

Brendon Smith

commit sha a44bbc2cc375d2cbc25f6d74f5f55e95efd5b34b

Increase VSCodium terminal scrollback Default is 1000. Not nearly enough for log output and tracebacks.

view details

Brendon Smith

commit sha 4cb536191bf92fe997d61100a30cd119be1daf16

Adjust dotfiles for work

view details

push time in 6 days

push eventbr3ndonland/dotfiles

Brendon Smith

commit sha 5ae7eb5ba6b8714d52a9ceaab0e042e7e4c33c63

Add GitHub token setting to bootstrap.sh br3ndonland/dotfiles@4ebb0ce - Add `STRAP_GITHUB_TOKEN` variable - Read `STRAP_GITHUB_TOKEN` from environment (instead of Strap web app) - Provide a notification message if `STRAP_GITHUB_TOKEN` is not set, without setting a value (to allow `[ -n $STRAP_GITHUB_TOKEN ]`)

view details

Brendon Smith

commit sha e091613939ae71484dcfb5f304cae643f61db4a2

Add pyenv to .zshrc

view details

Brendon Smith

commit sha a44bbc2cc375d2cbc25f6d74f5f55e95efd5b34b

Increase VSCodium terminal scrollback Default is 1000. Not nearly enough for log output and tracebacks.

view details

push time in 6 days

startedantonbabenko/serverless.tf

started time in 6 days

startedxwmx/nb

started time in 6 days

pull request commenttheskumar/python-dotenv

Improve load_dotenv exception and return behavior

Thanks for your feedback @bbc2. I agree that this is challenging, and that keeping the API simple will help us move forward. The latest commits will remove some of the complications introduced in 1011590 and b5a9613:

  • Remove raise_error_if_not_found and raise_error_if_nothing_set from load_dotenv
  • Remove the exception from load_dotenv
  • Restore previous return behavior of DotEnv.set_as_environment_variables (always returns True, even if dict is empty)

The simplest solution I have come up with so far is to use a conditional expression for f, allowing for more specific conditions.

# old
f = dotenv_path or stream or find_dotenv()
# new
f = dotenv_path if dotenv_path and find_dotenv(filename=str(dotenv_path)) else stream if stream else find_dotenv()

If the user runs load_dotenv(dotenv_path="filename"), resulting in f = dotenv_path, the path will now be passed to find_dotenv(). If no files or streams are available, load_dotenv will return False.

br3ndonland

comment created time in 6 days

push eventbr3ndonland/python-dotenv

Brendon Smith

commit sha 79128385655061e0d0a98e587f87ccdf48880b16

Fix Travis CI Python 3.5 Mypy error theskumar/python-dotenv#164 theskumar/python-dotenv#245 theskumar/python-dotenv#263 theskumar/python-dotenv@1011590 theskumar/python-dotenv@b5a9613 theskumar/python-dotenv@33cf7f4 https://travis-ci.com/github/theskumar/python-dotenv/jobs/401778048 lint run-test: commands[5] | mypy --python-version=3.5 src tests src/dotenv/main.py:319: error: Argument 1 to "DotEnv" has incompatible type "Iterable[str]"; expected "Union[str, str, StringIO]"

view details

push time in 6 days

startedpyenv/pyenv

started time in 6 days

push eventbr3ndonland/python-dotenv

Brendon Smith

commit sha 33cf7f44aac3515f434b8b35b668bef0264ed42d

Simplify load_dotenv exception and return behavior theskumar/python-dotenv#164 theskumar/python-dotenv#245 theskumar/python-dotenv#263 theskumar/python-dotenv@1011590 theskumar/python-dotenv@b5a9613 - Restore previous behavior of `DotEnv.set_as_environment_variables()`: Always returns `True`, even if dict is empty. - Remove the `raise_error_if_nothing_set` argument added in b5a9613 - Remove additional use of `raise_error_if_not_found` - Find `dotenv_path`: If `load_dotenv(dotenv_path="filename")` is run, resulting in `f = dotenv_path`, the path will now be passed to `find_dotenv()` to ensure the file can be found. If `find_dotenv()` can't find a .env file, `load_dotenv` will return `False`.

view details

push time in 6 days

PR closed tiangolo/uvicorn-gunicorn-docker

Iterate over Gunicorn processes with filter to avoid test failures

Description

tests/utils.py get_process_names() gets a list of Gunicorn processes. The list is then used by downstream tests to locate gunicorn_conf.py and verify the correct number of Gunicorn processes. top()["Processes"] returns a list of lists, with Gunicorn process names inside each list.

The index of the process name was hard-coded into get_process_names():

def get_process_names(container: Container) -> List[str]:
    top = container.top()
    process_commands = [p[7] for p in top["Processes"]]
    gunicorn_processes = [p for p in process_commands if "gunicorn" in p]
    return gunicorn_processes

This was causing test failures for me on my local machine, because the process names were in a different position (p[3] instead of p[7]).

{
    "Processes": [
        [
            "29173",
            "root",
            "0:00",
            "{gunicorn} /usr/local/bin/python /usr/local/bin/gunicorn -k uvicorn.workers.UvicornWorker -c /gunicorn_conf.py main:app",
        ],
        [
            "29207",
            "root",
            "0:00",
            "{gunicorn} /usr/local/bin/python /usr/local/bin/gunicorn -k uvicorn.workers.UvicornWorker -c /gunicorn_conf.py main:app",
        ],
        [
            "29208",
            "root",
            "0:00",
            "{gunicorn} /usr/local/bin/python /usr/local/bin/gunicorn -k uvicorn.workers.UvicornWorker -c /gunicorn_conf.py main:app",
        ],
    ],
    "Titles": ["PID", "USER", "TIME", "COMMAND"],
}

Changes

:recycle: A concise solution is to return an iterator with filter() instead:

def get_process_names(container: Container) -> List[Iterator[Any]]:
    return [filter(lambda i: "gunicorn" in i, p) for p in container.top()["Processes"]]

The iterator items are retrieved later by get_gunicorn_conf_path().

I took care of a couple of Poetry chores also:

  • :wrench: Update Poetry version to current release (4d541ad)
  • :wrench: Ignore local Poetry virtualenvs (f2a269e)
+7 -11

1 comment

3 changed files

br3ndonland

pr closed time in 7 days

pull request commenttiangolo/uvicorn-gunicorn-docker

Iterate over Gunicorn processes with filter to avoid test failures

Closing due to inactivity. I built an alternative project, br3ndonland/inboard, and will be focusing my efforts there.

br3ndonland

comment created time in 7 days

created tagbr3ndonland/inboard

tag0.5.8

🚢 Docker images to power your Python APIs and help you ship faster. With support for Uvicorn, Gunicorn, Starlette, and FastAPI.

created time in 7 days

more