GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 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.

Conversation

@zwimer

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

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.

zwimer reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Byron
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.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@zwimer @Byron
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.