← 返回首页
Prefer `import` to `__import__` by zwimer · Pull Request #82 · gitpython-developers/gitdb · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Prefer import to __import__#82

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

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

Conversation

Copy link
Copy Markdown
Contributor

zwimer commented Nov 23, 2022

What

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

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

Copy link
Copy Markdown
Member

Byron commented Nov 23, 2022

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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Footer

© 2026 GitHub, Inc.