← Winnitude! Search  ·  Reader Mode (822 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 27 LINKS

Prefer `import` to `__import__` by zwimer · Pull Request #82 · gitpython-developers/gitdb

This repository was archived by the owner on Jul 26, 2026. It is now read-only.

Repository navigation

Prefer import to __import__ - #82


Merged
Byron merged 2 commits into gitpython-developers:master from zwimer:prefer-standard-import Nov 23, 2022
Merged

Prefer import to __import__ #82 Byron merged 2 commits into gitpython-developers:master from zwimer:prefer-standard-import

Conversation

zwimer commented Nov 23, 2022



Copy link Copy Markdown
Contributor

What

In __init__.py there is a loop that invokes __import__ here:

gitdb/gitdb/__init__.py

Line 13 in 3415e08

def _init_externals ():

Since the loop only has one item this PR convert refactors it to use the standard import.

Why

Some tooling only works with modules to be imported via import as the packages names are resolve-able without executing code, which __import__ prevents.

Possible Changes

If it is desired to have smmap added into globals() of __init__.py; I can remove the del smmap line. Right now it is there because __import__, which import is replacing, does not add smmap to globals()

zwimer added 2 commits November 22, 2022 18:57 Prefer import to __import__ c3ab5d7 Add del smmap to match previous behavior 1edc7d2 zwimer mentioned this pull request Nov 23, 2022 Refactor installation and plugin management system binsync/binsync#219 Closed

Byron commented Nov 23, 2022



Copy link Copy Markdown
Member

Thanks a lot, this change is much appreciated. It's clear that this kind of __import__ logic isn't very useful here anymore, after all it's just a single module to import.

Byron merged commit 43de984 into gitpython-developers : master Nov 23, 2022 Sign up for free to subscribe to this conversation on GitHub . Already have an account? Sign in .

Labels

None yet

2 participants