mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-11-15 00:37:13 +00:00
flake8: fix nested import checks
Import modules at the top of the module in most cases. Many of these weren't actually saving any time: * editor: shlex is already imported by the main module * platform_utils: On Windows, the win32 module is almost always needed * tests: There's no point in optimizing these. The trace import in the main module is about the only one worth allowing since that module itself is rarely used, and only when in a specific debug mode. Change-Id: I5d3fcecbe51e0ce78d4e856d7033565150ef4526 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/654103 Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Brian Gan <brgan@google.com> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
1 parent
d621aa8ee4
commit
7ed9700a95
5 files changed
+11
-14
No files matched your search
@@ -21,6 +21,7 @@ import pytest
|
||||
|
||||
from command import Command
|
||||
import subcmds
|
||||
from subcmds import sync
|
||||
|
||||
|
||||
# NB: We don't test all subcommands as we want to avoid "change detection"
|
||||
@@ -164,9 +165,7 @@ def test_common_validate_options(name: str, cls: Type[Command]) -> None:
|
||||
|
||||
def test_attribute_error_repro() -> None:
|
||||
"""Confirm that accessing verbose before CommonValidateOptions fails."""
|
||||
from subcmds.sync import Sync
|
||||
|
||||
cmd = Sync()
|
||||
cmd = sync.Sync()
|
||||
opts, args = cmd.OptionParser.parse_args([])
|
||||
|
||||
# This confirms that without the fix in main.py, an AttributeError
|
||||
|
||||
@@ -19,6 +19,7 @@ import optparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
@@ -3012,8 +3013,6 @@ class TestSmartSyncSetupRemoteHelper(unittest.TestCase):
|
||||
self, mock_transport_class, mock_server_class, mock_popen, mock_which
|
||||
):
|
||||
"""Test _SmartSyncSetup when a helper is present and succeeds."""
|
||||
import subprocess
|
||||
|
||||
self.manifest.manifest_server = (
|
||||
"persistent-https://android-smartsync.corp.google.com/"
|
||||
"manifestserver"
|
||||
|
||||
Reference in new issue
Block a user