Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replace all wildcard imports with explicit imports#1880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 34 commits intogitpython-developers:mainfromEliahKagan:imports
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
34 commits
Select commitHold shift + click to select a range
1e5a944
Add a script to validate refactored imports
EliahKaganMar 17, 2024
5b2771d
Add regression tests of the git.util aliasing situation
EliahKaganMar 18, 2024
fc86a23
Incompletely change git.index imports to test modattrs.py
EliahKaganFeb 24, 2024
4badc19
Fix git.index imports
EliahKaganMar 18, 2024
1c9bda2
Improve relative order of import groups, and __all__, in git.index
EliahKaganMar 18, 2024
8b51af3
Improve order of imports and __all__ in git.refs submodules
EliahKaganMar 18, 2024
b25dd7e
Replace wildcard imports in git.refs
EliahKaganMar 18, 2024
b32ef65
Improve order of imports and __all__ in git.repo submodules
EliahKaganMar 18, 2024
0ba06e9
Add git.repo.__all__ and make submodules explicit
EliahKaganMar 18, 2024
c946906
Improve order of imports and __all__ in git.objects.*
EliahKaganMar 18, 2024
4e9a2f2
Improve order of imports and __all__ in git.object.submodule.*
EliahKaganMar 18, 2024
c58be4c
Remove a bit of old commented-out code in git.objects.*
EliahKaganMar 18, 2024
01c95eb
Don't patch IndexObject and Object into git.objects.submodule.util
EliahKaganMar 18, 2024
f89d065
Fix git.objects.__all__ and make submodules explicit
EliahKaganMar 18, 2024
3786307
Make git.objects.util module docstring more specific
EliahKaganMar 18, 2024
de540b7
Add __all__ and imports in git.objects.submodule
EliahKaganMar 18, 2024
a05597a
Improve how imports and __all__ are written in git.util
EliahKaganMar 18, 2024
2053a3d
Remove old commented-out change_type assertions in git.diff
EliahKaganMar 18, 2024
b8bab43
Remove old commented-out flagKeyLiteral assertions in git.remote
EliahKaganMar 19, 2024
3d4e476
Improve how second-level imports and __all__ are written
EliahKaganMar 19, 2024
6318eea
Make F401 "unused import" suppressions more specific
EliahKaganMar 19, 2024
31bc8a4
Remove unneeded F401 "Unused import" suppressions
EliahKaganMar 19, 2024
abbe74d
Fix a tiny import sorting nit
EliahKaganMar 19, 2024
7745250
Replace wildcard imports in top-level git module
EliahKaganMar 19, 2024
64c9efd
Restore relative order to fix circular import error
EliahKaganMar 19, 2024
31f89a1
Add the nonpublic indirect submodule aliases back for now
EliahKaganMar 19, 2024
9bbbcb5
Further improve git.objects.util module docstring
EliahKaganMar 19, 2024
00f4cbc
Add missing submodule imports in git.objects
EliahKaganMar 19, 2024
fcc7418
Don't explicitly list direct submodules in __all__
EliahKaganMar 19, 2024
78055a8
Pick a consistent type for __all__ (for now, list)
EliahKaganMar 19, 2024
ecdb6aa
Save diff of non-__all__ attributes across import changes
EliahKaganMar 19, 2024
f705fd6
Remove modattrs.py and related
EliahKaganMar 19, 2024
4a4d880
Improve test suite import grouping/sorting, __all__ placement
EliahKaganMar 19, 2024
d524c76
Fix slightly unsorted imports in setup.py
EliahKaganMar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 97 additions & 17 deletionsgit/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

# @PydevCodeAnalysisIgnore

__all__ = [ # noqa: F405
__all__ = [
"Actor",
"AmbiguousObjectName",
"BadName",
Expand DownExpand Up@@ -88,32 +88,112 @@

__version__ = "git"

from typing import List, Optional, Sequence,Tuple, Union, TYPE_CHECKING
from typing import List, Optional, Sequence,TYPE_CHECKING, Tuple, Union

from gitdb.util import to_hex_sha
from git.exc import * # noqa: F403 # @NoMove @IgnorePep8

from git.exc import (
AmbiguousObjectName,
BadName,
BadObject,
BadObjectType,
CacheError,
CheckoutError,
CommandError,
GitCommandError,
GitCommandNotFound,
GitError,
HookExecutionError,
InvalidDBRoot,
InvalidGitRepositoryError,
NoSuchPathError,
ODBError,
ParseError,
RepositoryDirtyError,
UnmergedEntriesError,
UnsafeOptionError,
UnsafeProtocolError,
UnsupportedOperation,
WorkTreeRepositoryUnsupported,
)
from git.types import PathLike

try:
from git.compat import safe_decode # @NoMove @IgnorePep8
from git.config import GitConfigParser # @NoMove @IgnorePep8
from git.objects import * # noqa: F403 # @NoMove @IgnorePep8
from git.refs import * # noqa: F403 # @NoMove @IgnorePep8
from git.diff import * # noqa: F403 # @NoMove @IgnorePep8
from git.db import * # noqa: F403 # @NoMove @IgnorePep8
from git.cmd import Git # @NoMove @IgnorePep8
from git.repo import Repo # @NoMove @IgnorePep8
from git.remote import * # noqa: F403 # @NoMove @IgnorePep8
from git.index import * # noqa: F403 # @NoMove @IgnorePep8
from git.util import ( # @NoMove @IgnorePep8
LockFile,
from git.compat import safe_decode # @NoMove
from git.config import GitConfigParser # @NoMove
from git.objects import ( # @NoMove
Blob,
Commit,
IndexObject,
Object,
RootModule,
RootUpdateProgress,
Submodule,
TagObject,
Tree,
TreeModifier,
UpdateProgress,
)
from git.refs import ( # @NoMove
HEAD,
Head,
RefLog,
RefLogEntry,
Reference,
RemoteReference,
SymbolicReference,
Tag,
TagReference,
head, # noqa: F401 # Nonpublic. May disappear! Use git.refs.head.
log, # noqa: F401 # Nonpublic. May disappear! Use git.refs.log.
reference, # noqa: F401 # Nonpublic. May disappear! Use git.refs.reference.
symbolic, # noqa: F401 # Nonpublic. May disappear! Use git.refs.symbolic.
tag, # noqa: F401 # Nonpublic. May disappear! Use git.refs.tag.
)
from git.diff import ( # @NoMove
INDEX,
NULL_TREE,
Diff,
DiffConstants,
DiffIndex,
Diffable,
)
from git.db import GitCmdObjectDB, GitDB # @NoMove
from git.cmd import Git # @NoMove
from git.repo import Repo # @NoMove
from git.remote import FetchInfo, PushInfo, Remote, RemoteProgress # @NoMove
from git.index import ( # @NoMove
BaseIndexEntry,
BlobFilter,
CheckoutError,
IndexEntry,
IndexFile,
StageType,
base, # noqa: F401 # Nonpublic. May disappear! Use git.index.base.
fun, # noqa: F401 # Nonpublic. May disappear! Use git.index.fun.
typ, # noqa: F401 # Nonpublic. May disappear! Use git.index.typ.
#
# NOTE: The expression `git.util` evaluates to git.index.util, and the import
# `from git import util` imports git.index.util, NOT git.util. It may not be
# feasible to change this until the next major version, to avoid breaking code
# inadvertently relying on it. If git.index.util really is what you want, use or
# import from that name, to avoid confusion. To use the "real" git.util module,
# write `from git.util import ...`, or access it as `sys.modules["git.util"]`.
# (This differs from other historical indirect-submodule imports that are
# unambiguously nonpublic and are subject to immediate removal. Here, the public
# git.util module, even though different, makes it less discoverable that the
# expression `git.util` refers to a non-public attribute of the git module.)
util, # noqa: F401
)
from git.util import ( # @NoMove
Actor,
BlockingLockFile,
LockFile,
Stats,
Actor,
remove_password_if_present,
rmtree,
)
except GitError as _exc: # noqa: F405
except GitError as _exc:
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc

# { Initialize git executable path
Expand Down
15 changes: 7 additions & 8 deletionsgit/cmd.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,18 +5,20 @@

from __future__ import annotations

import re
__all__ = ["Git"]

import contextlib
import io
import itertools
import logging
import os
import re
import signal
from subprocess import Popen, PIPE, DEVNULL
import subprocess
from subprocess import DEVNULL, PIPE, Popen
import sys
import threading
from textwrap import dedent
import threading

from git.compat import defenc, force_bytes, safe_decode
from git.exc import (
Expand DownExpand Up@@ -57,12 +59,11 @@
overload,
)

from git.types importPathLike, Literal, TBD
from git.types importLiteral, PathLike, TBD

if TYPE_CHECKING:
from git.repo.base import Repo
from git.diff import DiffIndex

from git.repo.base import Repo

# ---------------------------------------------------------------------------------

Expand All@@ -84,8 +85,6 @@

_logger = logging.getLogger(__name__)

__all__ = ("Git",)


# ==============================================================================
## @name Utilities
Expand Down
14 changes: 7 additions & 7 deletionsgit/compat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,18 +14,18 @@
import os
import sys

from gitdb.utils.encoding import force_bytes, force_text # noqa: F401 # @UnusedImport
from gitdb.utils.encoding import force_bytes, force_text # noqa: F401

# typing --------------------------------------------------------------------

from typing import ( # noqa: F401
Any,
from typing import (
Any, # noqa: F401
AnyStr,
Dict,
IO,
Dict, # noqa: F401
IO, # noqa: F401
Optional,
Tuple,
Type,
Tuple, # noqa: F401
Type, # noqa: F401
Union,
overload,
)
Expand Down
7 changes: 4 additions & 3 deletionsgit/config.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,8 @@

"""Parser for reading and writing configuration files."""

__all__ = ["GitConfigParser", "SectionConstraint"]

import abc
import configparser as cp
import fnmatch
Expand DownExpand Up@@ -40,9 +42,10 @@
from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, assert_never, _T

if TYPE_CHECKING:
from git.repo.base import Repo
from io import BytesIO

from git.repo.base import Repo

T_ConfigParser = TypeVar("T_ConfigParser", bound="GitConfigParser")
T_OMD_value = TypeVar("T_OMD_value", str, bytes, int, float, bool)

Expand All@@ -58,8 +61,6 @@

# -------------------------------------------------------------

__all__ = ("GitConfigParser", "SectionConstraint")

_logger = logging.getLogger(__name__)

CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository")
Expand Down
13 changes: 6 additions & 7 deletionsgit/db.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,27 +3,26 @@

"""Module with our own gitdb implementation - it uses the git command."""

from git.util import bin_to_hex, hex_to_bin
from gitdb.base import OInfo, OStream
from gitdb.db import GitDB
from gitdb.db import LooseObjectDB
__all__ = ["GitCmdObjectDB", "GitDB"]

from gitdb.base import OInfo, OStream
from gitdb.db import GitDB, LooseObjectDB
from gitdb.exc import BadObject

from git.util import bin_to_hex, hex_to_bin
from git.exc import GitCommandError

# typing-------------------------------------------------

from typing import TYPE_CHECKING

from git.types import PathLike

if TYPE_CHECKING:
from git.cmd import Git


# --------------------------------------------------------

__all__ = ("GitCmdObjectDB", "GitDB")


class GitCmdObjectDB(LooseObjectDB):
"""A database representing the default git object store, which includes loose
Expand Down
30 changes: 11 additions & 19 deletionsgit/diff.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,17 +3,17 @@
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

__all__ = ["DiffConstants", "NULL_TREE", "INDEX", "Diffable", "DiffIndex", "Diff"]

import enum
import re

from git.cmd import handle_process_output
from git.compat import defenc
from git.objects.blob import Blob
from git.objects.util import mode_str_to_int
from git.util import finalize_process, hex_to_bin

from .objects.blob import Blob
from .objects.util import mode_str_to_int


# typing ------------------------------------------------------------------

from typing import (
Expand All@@ -23,34 +23,27 @@
Match,
Optional,
Tuple,
TYPE_CHECKING,
TypeVar,
Union,
TYPE_CHECKING,
cast,
)
from git.types import Literal, PathLike

if TYPE_CHECKING:
from .objects.tree import Tree
from .objects import Commit
from git.repo.base import Repo
from git.objects.base import IndexObject
from subprocess import Popen
from git import Git

Lit_change_type = Literal["A", "D", "C", "M", "R", "T", "U"]

from git.cmd import Git
from git.objects.base import IndexObject
from git.objects.commit import Commit
from git.objects.tree import Tree
from git.repo.base import Repo

# def is_change_type(inp: str) -> TypeGuard[Lit_change_type]:
# # return True
# return inp in ['A', 'D', 'C', 'M', 'R', 'T', 'U']
Lit_change_type = Literal["A", "D", "C", "M", "R", "T", "U"]

# ------------------------------------------------------------------------


__all__ = ("DiffConstants", "NULL_TREE", "INDEX", "Diffable", "DiffIndex", "Diff")


@enum.unique
class DiffConstants(enum.Enum):
"""Special objects for :meth:`Diffable.diff`.
Expand DownExpand Up@@ -693,7 +686,6 @@ def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex) -> Non
# Change type can be R100
# R: status letter
# 100: score (in case of copy and rename)
# assert is_change_type(_change_type[0]), f"Unexpected value for change_type received: {_change_type[0]}"
change_type: Lit_change_type = cast(Lit_change_type, _change_type[0])
score_str = "".join(_change_type[1:])
score = int(score_str) if score_str.isdigit() else None
Expand Down
4 changes: 3 additions & 1 deletiongit/exc.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,12 +42,14 @@
ParseError,
UnsupportedOperation,
)

from git.compat import safe_decode
from git.util import remove_password_if_present

# typing ----------------------------------------------------

from typing import List, Sequence, Tuple, Union, TYPE_CHECKING
from typing import List, Sequence, Tuple, TYPE_CHECKING, Union

from git.types import PathLike

if TYPE_CHECKING:
Expand Down
13 changes: 11 additions & 2 deletionsgit/index/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,5 +3,14 @@

"""Initialize the index package."""

from .base import * # noqa: F401 F403
from .typ import * # noqa: F401 F403
__all__ = [
"BaseIndexEntry",
"BlobFilter",
"CheckoutError",
"IndexEntry",
"IndexFile",
"StageType",
]

from .base import CheckoutError, IndexFile
from .typ import BaseIndexEntry, BlobFilter, IndexEntry, StageType
Loading

[8]ページ先頭

©2009-2025 Movatter.jp