gitpython-developers / gitdb

IO of git-style object databases
http://gitdb.readthedocs.org
Other
212 stars 65 forks source link

Prefer `import` to `__import__` #82

Closed zwimer closed 1 year ago

zwimer commented 1 year ago

What

In __init__.py there is a loop that invokes __import__ here: https://github.com/gitpython-developers/gitdb/blob/3415e08bd9590d489f1071815863bfdde3083fb3/gitdb/__init__.py#L13

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()

Byron commented 1 year ago

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.