Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
apply import merging for . (1 of 1)
Browse files Browse the repository at this point in the history
Summary:
Applies new import merging and sorting from µsort v1.0.

When merging imports, µsort will make a best-effort to move associated
comments to match merged elements, but there are known limitations due to
the diynamic nature of Python and developer tooling. These changes should
not produce any dangerous runtime changes, but may require touch-ups to
satisfy linters and other tooling.

Note that µsort uses case-insensitive, lexicographical sorting, which
results in a different ordering compared to isort. This provides a more
consistent sorting order, matching the case-insensitive order used when
sorting import statements by module name, and ensures that "frog", "FROG",
and "Frog" always sort next to each other.

For details on µsort's sorting and merging semantics, see the user guide:
https://usort.readthedocs.io/en/stable/guide.html#sorting

Reviewed By: lisroach

Differential Revision: D36402269

fbshipit-source-id: fa77bafb09e935a0a21065dbc23d66c325b271c2
  • Loading branch information
amyreese authored and facebook-github-bot committed May 15, 2022
1 parent b2628d3 commit d55c0c7
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 77 deletions.
5 changes: 1 addition & 4 deletions cpp/codegen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

import argparse
import importlib
Expand Down
5 changes: 1 addition & 4 deletions cpp/codegen/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

import abc
import re
Expand Down
13 changes: 6 additions & 7 deletions cpp/codegen/codegen_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

import hashlib
import re

from .codegen import Language
from .cpp import entry_types as cpp_entry_types # noqa: E402
from .cpp import entry_structs as cpp_entry_structs # noqa: E402
from .cpp import parser as cpp_parser # noqa: E402
from .cpp import ( # noqa: E402 # noqa: E402 # noqa: E402
entry_structs as cpp_entry_structs,
entry_types as cpp_entry_types,
parser as cpp_parser,
)
from .java import entry_types as java_entry_types # noqa: E402


Expand Down
14 changes: 4 additions & 10 deletions cpp/codegen/config/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from ..codegen import EntryDescription
from ..codegen import MemoryDescription
from ..types import Types
from ..types import DynamicArrayType
from ..types import EntryTypeEnum
from __future__ import absolute_import, division, print_function, unicode_literals

from ..codegen import EntryDescription, MemoryDescription
from ..types import DynamicArrayType, EntryTypeEnum, Types

NAMES = [
"UNKNOWN_TYPE",
Expand Down
5 changes: 1 addition & 4 deletions cpp/codegen/configloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

import importlib

Expand Down
8 changes: 2 additions & 6 deletions cpp/codegen/cpp/entry_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

from ..codegen import Codegen
from ..codegen import SIGNED_SOURCE
from ..codegen import Codegen, SIGNED_SOURCE
from ..types import DynamicArrayType
from .type_converter import TypeConverter

Expand Down
8 changes: 2 additions & 6 deletions cpp/codegen/cpp/entry_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

from ..codegen import Codegen
from ..codegen import SIGNED_SOURCE
from ..codegen import Codegen, SIGNED_SOURCE


class CppEntryTypesCodegen(Codegen):
Expand Down
8 changes: 2 additions & 6 deletions cpp/codegen/cpp/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

from ..codegen import Codegen
from ..codegen import SIGNED_SOURCE
from ..codegen import Codegen, SIGNED_SOURCE


class CppParserCodegen(Codegen):
Expand Down
5 changes: 1 addition & 4 deletions cpp/codegen/cpp/type_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

from .type_converters import CONVERTERS

Expand Down
19 changes: 9 additions & 10 deletions cpp/codegen/cpp/type_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

import abc

from ..codegen import Codegen
from ..types import ArrayType
from ..types import CompoundType
from ..types import DynamicArrayType
from ..types import EntryTypeEnum
from ..types import IntegerType
from ..types import PointerType
from ..types import (
ArrayType,
CompoundType,
DynamicArrayType,
EntryTypeEnum,
IntegerType,
PointerType,
)


class CppTypeConverter(object, metaclass=abc.ABCMeta):
Expand Down
8 changes: 2 additions & 6 deletions cpp/codegen/java/entry_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

from ..codegen import Codegen
from ..codegen import SIGNED_SOURCE
from ..codegen import Codegen, SIGNED_SOURCE


class JavaEntryTypesCodegen(Codegen):
Expand Down
5 changes: 1 addition & 4 deletions cpp/codegen/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
limitations under the License.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

import abc

Expand Down
4 changes: 2 additions & 2 deletions python/profilo/importer/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

from functools import cmp_to_key

from ..model.build import Trace, StackTrace
from ..model.build import StackTrace, Trace
from .constants import COUNTER_NAMES
from .trace_file import StandardEntry, BytesEntry
from .trace_file import BytesEntry, StandardEntry


def entry_compare(x, y):
Expand Down
2 changes: 1 addition & 1 deletion python/profilo/model/tests/intervals_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import unittest

from ..intervals import IntervalTree, Interval
from ..intervals import Interval, IntervalTree


class IntervalTests(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion python/profilo/profilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import argparse

from .device.device import pull_last_trace, pull_all_traces, pull_n_traces
from .device.device import pull_all_traces, pull_last_trace, pull_n_traces

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Profilo commandline utility!")
Expand Down
3 changes: 1 addition & 2 deletions python/profilo/workflow_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

import argparse
import zipfile
from collections import defaultdict
from collections import namedtuple
from collections import defaultdict, namedtuple

import numpy as np
import pandas as pd
Expand Down

0 comments on commit d55c0c7

Please sign in to comment.