Skip to content

Commit

Permalink
Sort imports
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Feb 12, 2021
1 parent 5079e2b commit 217d9da
Show file tree
Hide file tree
Showing 28 changed files with 140 additions and 125 deletions.
4 changes: 2 additions & 2 deletions emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Helper binary used by test_shell.py to print interleaved sequences
# of strings to stderr/stdout.

import sys
from typing import Sequence, TypeVar, Tuple, Iterator
import itertools
import sys
from typing import Iterator, Sequence, Tuple, TypeVar

T = TypeVar('T')

Expand Down
22 changes: 10 additions & 12 deletions ghstack/__main__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#!/usr/bin/env python3

import ghstack
import argparse
import asyncio

import ghstack.submit
import ghstack.unlink
import ghstack.rage
import ghstack.land
import ghstack
import ghstack.action
import ghstack.status
import ghstack.checkout

import ghstack.logging
import ghstack.github_real
import ghstack.circleci_real
import ghstack.config

import argparse
import asyncio
import ghstack.github_real
import ghstack.land
import ghstack.logging
import ghstack.rage
import ghstack.status
import ghstack.submit
import ghstack.unlink


def main() -> None:
Expand Down
8 changes: 4 additions & 4 deletions ghstack/action.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python3

import ghstack.shell
import logging
from typing import Optional

import ghstack.github
import ghstack.github_utils

from typing import Optional
import logging
import ghstack.shell


def main(pull_request: str,
Expand Down
2 changes: 1 addition & 1 deletion ghstack/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# - Concurrency safe
# - Handles eviction

import sqlite3
import os
import sqlite3
from typing import Optional

_handle: Optional[sqlite3.Connection] = None
Expand Down
8 changes: 4 additions & 4 deletions ghstack/checkout.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3

import ghstack.shell
import ghstack.github
import ghstack.github_utils

import logging
import re

import ghstack.github
import ghstack.github_utils
import ghstack.shell


def main(pull_request: str,
github: ghstack.github.GitHubEndpoint,
Expand Down
10 changes: 5 additions & 5 deletions ghstack/circleci_real.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env python3

from typing import Optional, Any
import logging
import json
import aiohttp
import logging
import re
from typing import Any, Optional

import ghstack.circleci
import ghstack.cache
import aiohttp

import ghstack.cache
import ghstack.circleci

RE_BUILD_PATH = re.compile(r'^project/github/[^/]+/[^/]+/[0-9]+$')

Expand Down
7 changes: 3 additions & 4 deletions ghstack/config.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env python3

import os
import getpass
import configparser
import getpass
import logging
import os
import re
from typing import NamedTuple, Optional
from pathlib import Path
from typing import NamedTuple, Optional

import ghstack.logging


Config = NamedTuple('Config', [
# Proxy to use when making connections to GitHub
('proxy', Optional[str]),
Expand Down
8 changes: 4 additions & 4 deletions ghstack/diff.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3

from dataclasses import dataclass
from ghstack.typing import GitHubNumber, GitTreeHash
import ghstack.shell
from typing import Optional, Pattern
import re
from abc import ABCMeta, abstractmethod
from dataclasses import dataclass
from typing import Optional, Pattern

import ghstack.shell
from ghstack.typing import GitHubNumber, GitTreeHash

RE_GH_METADATA = re.compile(
r'gh-metadata: (?P<owner>[^/]+) (?P<repo>[^/]+) (?P<number>[0-9]+) '
Expand Down
10 changes: 4 additions & 6 deletions ghstack/expecttest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import re
import unittest
import traceback
import os
import re
import string

from typing import List, Dict, Tuple, Match, Optional

import traceback
import unittest
from typing import Dict, List, Match, Optional, Tuple

ACCEPT = os.getenv('EXPECTTEST_ACCEPT')

Expand Down
9 changes: 5 additions & 4 deletions ghstack/forensics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
# This script looks at all commits downloads their logs and prints them
# for you

import ghstack.github
import ghstack.circleci
import ghstack.github_utils

import re
from typing import Any, Dict

import aiohttp

import ghstack.circleci
import ghstack.github
import ghstack.github_utils

RE_CIRCLECI_URL = re.compile(r'^https://circleci.com/gh/pytorch/pytorch/([0-9]+)')


Expand Down
8 changes: 4 additions & 4 deletions ghstack/git.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python3

from typing import Pattern, List
from ghstack.typing import GitCommitHash, GitTreeHash
import ghstack.shell
import ghstack.diff
import re
from typing import List, Pattern

import ghstack.diff
import ghstack.shell
from ghstack.typing import GitCommitHash, GitTreeHash

RE_RAW_COMMIT_ID = re.compile(r'^(?P<commit>[a-f0-9]+)$', re.MULTILINE)
RE_RAW_AUTHOR = re.compile(r'^author (?P<author>(?P<name>[^<]+?) <(?P<email>[^>]+)>)',
Expand Down
15 changes: 6 additions & 9 deletions ghstack/github_fake.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#!/usr/bin/env python3

import graphql

import re
import os.path
import re
from dataclasses import dataclass # Oof! Python 3.7 only!!
from typing import Any, Dict, List, NewType, Optional, Sequence, cast

# Oof! Python 3.7 only!!
from dataclasses import dataclass

from typing import Dict, NewType, List, Optional, Any, Sequence, cast
from ghstack.typed_dict import TypedDict
import graphql

import ghstack.shell
import ghstack.github
import ghstack.shell
from ghstack.typed_dict import TypedDict

GraphQLId = NewType('GraphQLId', str)
GitHubNumber = NewType('GitHubNumber', int)
Expand Down
5 changes: 3 additions & 2 deletions ghstack/github_real.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python3

import json
import requests
from typing import Optional, Any, Sequence, Union, Tuple
import logging
from typing import Any, Optional, Sequence, Tuple, Union

import requests

import ghstack.github

Expand Down
3 changes: 2 additions & 1 deletion ghstack/github_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python3

import re
from typing import Dict, Any
from typing import Any, Dict

try:
from mypy_extensions import TypedDict
except ImportError:
Expand Down
12 changes: 6 additions & 6 deletions ghstack/land.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env python3

import ghstack.shell
import ghstack.github
import ghstack.github_utils
import ghstack.git
from ghstack.typing import GitCommitHash

import logging
import re
from typing import Optional

import ghstack.git
import ghstack.github
import ghstack.github_utils
import ghstack.shell
from ghstack.typing import GitCommitHash


def lookup_pr_to_orig_ref(github: ghstack.github.GitHubEndpoint, *, github_url: Optional[str] = None, owner: str, name: str, number: int) -> str:
pr_result = github.graphql("""
Expand Down
15 changes: 7 additions & 8 deletions ghstack/logging.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/env python3

import subprocess
import os
import contextlib
import datetime
import functools
import logging
import os
import re
import datetime
import uuid
import shutil
import subprocess
import sys
import logging
import contextlib
from typing import Dict, Optional, Iterator

import uuid
from typing import Dict, Iterator, Optional

DATETIME_FORMAT = '%Y-%m-%d_%Hh%Mm%Ss'

Expand Down
6 changes: 3 additions & 3 deletions ghstack/rage.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3

import ghstack
import ghstack.logging
import os
import datetime
import os
import tempfile
from typing import Dict, NewType

import ghstack
import ghstack.logging

RawIndex = NewType('RawIndex', int)
FilteredIndex = NewType('FilteredIndex', int)
Expand Down
10 changes: 5 additions & 5 deletions ghstack/shell.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3

import subprocess
import os
import logging
from typing import Dict, Sequence, Optional, TypeVar, Union, Any, overload, IO, Tuple
import asyncio
import logging
import os
import subprocess
import sys

from typing import (IO, Any, Dict, Optional, Sequence, Tuple, TypeVar, Union,
overload)

# Shell commands generally return str, but with exitcode=True
# they return a bool, and if stdout is piped straight to sys.stdout
Expand Down
13 changes: 7 additions & 6 deletions ghstack/status.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import ghstack.github
import ghstack.circleci
import ghstack.github_utils
from ghstack.typed_dict import TypedDict

import asyncio
import re
import logging
import re

import aiohttp

import ghstack.circleci
import ghstack.github
import ghstack.github_utils
from ghstack.typed_dict import TypedDict

RE_CIRCLECI_URL = re.compile(r'^https://circleci.com/gh/pytorch/pytorch/([0-9]+)')


Expand Down
12 changes: 7 additions & 5 deletions ghstack/submit.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/usr/bin/env python3

import logging
import re
from dataclasses import dataclass
from typing import List, NamedTuple, Optional, Set, Tuple

import ghstack
import ghstack.git
import ghstack.shell
import ghstack.github
import ghstack.logging
from ghstack.typing import GitHubNumber, GitHubRepositoryId, GhNumber, GitCommitHash, GitTreeHash
from typing import List, Optional, NamedTuple, Tuple, Set
import logging
from dataclasses import dataclass
import ghstack.shell
from ghstack.typing import (GhNumber, GitCommitHash, GitHubNumber,
GitHubRepositoryId, GitTreeHash)

# Either "base", "head" or "orig"; which of the ghstack generated
# branches this diff corresponds to
Expand Down
3 changes: 2 additions & 1 deletion ghstack/typed_dict.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Dict, Any
from typing import Any, Dict

# TODO: do something better about this...
try:
from mypy_extensions import TypedDict as TypedDict
Expand Down
Loading

0 comments on commit 217d9da

Please sign in to comment.