Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ufmt to format code #213

Merged
merged 2 commits into from Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -73,8 +73,8 @@ Start by setting up and activating a virtualenv:
# If you're done with the virtualenv, you can leave it by running:
deactivate

We use `isort <https://isort.readthedocs.io/en/stable/>`_ and `black <https://black.readthedocs.io/en/stable/>`_
to format code. To format changes to be conformant, run the following in the root:
We use `ufmt <https://ufmt.omnilib.dev/en/stable/>`_ to format code. To format
changes to be conformant, run the following in the root:

.. code-block:: shell

Expand Down
4 changes: 2 additions & 2 deletions fixit/cli/__init__.py
Expand Up @@ -16,7 +16,6 @@
from dataclasses import asdict, dataclass, field
from pathlib import Path
from typing import (
TYPE_CHECKING,
Callable,
Collection,
Dict,
Expand All @@ -28,14 +27,15 @@
Sequence,
Tuple,
Type,
TYPE_CHECKING,
TypeVar,
Union,
)

import libcst as cst
from libcst.metadata import MetadataWrapper

from fixit.cli.args import LintWorkers, get_multiprocessing_parser
from fixit.cli.args import get_multiprocessing_parser, LintWorkers
from fixit.common.base import LintConfig
from fixit.common.config import get_lint_config
from fixit.common.full_repo_metadata import FullRepoMetadataConfig, get_repo_caches
Expand Down
8 changes: 4 additions & 4 deletions fixit/cli/apply_fix.py
Expand Up @@ -17,15 +17,14 @@
from dataclasses import dataclass
from multiprocessing import Manager
from pathlib import Path
from typing import TYPE_CHECKING, Iterable, List, Mapping, Optional
from typing import Iterable, List, Mapping, Optional, TYPE_CHECKING

from libcst import ParserSyntaxError, parse_module
from libcst import parse_module, ParserSyntaxError
from libcst.codemod._cli import invoke_formatter
from libcst.metadata import MetadataWrapper

from fixit.cli import find_files, map_paths
from fixit.cli.args import (
LintWorkers,
get_compact_parser,
get_metadata_cache_parser,
get_multiprocessing_parser,
Expand All @@ -34,6 +33,7 @@
get_skip_autoformatter_parser,
get_skip_ignore_byte_marker_parser,
get_skip_ignore_comments_parser,
LintWorkers,
)
from fixit.cli.formatter import LintRuleReportFormatter
from fixit.cli.full_repo_metadata import (
Expand All @@ -45,8 +45,8 @@
from fixit.common.report import BaseLintRuleReport
from fixit.common.utils import LintRuleCollectionT
from fixit.rule_lint_engine import (
LintRuleReportsWithAppliedPatches,
lint_file_and_apply_patches,
LintRuleReportsWithAppliedPatches,
)


Expand Down
2 changes: 1 addition & 1 deletion fixit/cli/args.py
Expand Up @@ -12,9 +12,9 @@
from fixit.common.base import LintRuleT
from fixit.common.config import get_lint_config, get_rules_from_config
from fixit.common.utils import (
LintRuleNotFoundError,
find_and_import_rule,
import_distinct_rules_from_package,
LintRuleNotFoundError,
)


Expand Down
4 changes: 2 additions & 2 deletions fixit/cli/full_repo_metadata.py
Expand Up @@ -4,9 +4,9 @@
# LICENSE file in the root directory of this source tree.

from collections import defaultdict
from logging import Handler, Logger, LogRecord, getLogger
from logging import getLogger, Handler, Logger, LogRecord
from subprocess import TimeoutExpired
from typing import TYPE_CHECKING, DefaultDict, Iterable, List, Mapping, Type
from typing import DefaultDict, Iterable, List, Mapping, Type, TYPE_CHECKING

from libcst.metadata import TypeInferenceProvider

Expand Down
6 changes: 3 additions & 3 deletions fixit/cli/insert_suppressions.py
Expand Up @@ -17,9 +17,9 @@
from dataclasses import dataclass
from enum import Enum
from pathlib import Path
from typing import TYPE_CHECKING, Iterable, List, Mapping, Optional, Union
from typing import Iterable, List, Mapping, Optional, TYPE_CHECKING, Union

from libcst import ParserSyntaxError, parse_module
from libcst import parse_module, ParserSyntaxError
from libcst.codemod._cli import invoke_formatter
from libcst.metadata import MetadataWrapper

Expand All @@ -41,9 +41,9 @@
from fixit.common.base import LintRuleT
from fixit.common.config import get_lint_config
from fixit.common.insert_suppressions import (
insert_suppressions,
SuppressionComment,
SuppressionCommentKind,
insert_suppressions,
)
from fixit.common.report import BaseLintRuleReport
from fixit.rule_lint_engine import lint_file
Expand Down
4 changes: 2 additions & 2 deletions fixit/cli/run_rules.py
Expand Up @@ -19,9 +19,9 @@
import time
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Iterable, List, Mapping, Optional
from typing import Iterable, List, Mapping, Optional, TYPE_CHECKING

from libcst import ParserSyntaxError, parse_module
from libcst import parse_module, ParserSyntaxError
from libcst.metadata import MetadataWrapper

from fixit.cli import find_files, map_paths
Expand Down
2 changes: 1 addition & 1 deletion fixit/cli/tests/test_formatter.py
Expand Up @@ -7,7 +7,7 @@
import libcst as cst
from libcst.testing.utils import UnitTest

from fixit.cli.formatter import LintRuleReportFormatter, format_warning
from fixit.cli.formatter import format_warning, LintRuleReportFormatter
from fixit.common.report import BaseLintRuleReport, CstLintRuleReport


Expand Down
2 changes: 1 addition & 1 deletion fixit/cli/tests/test_lint_opts.py
Expand Up @@ -5,7 +5,7 @@

from dataclasses import dataclass
from pathlib import Path
from typing import Collection, List, Optional, Sequence, cast
from typing import cast, Collection, List, Optional, Sequence

from libcst import Module
from libcst.testing.utils import UnitTest
Expand Down
2 changes: 1 addition & 1 deletion fixit/common/base.py
Expand Up @@ -7,7 +7,7 @@
from abc import ABCMeta
from dataclasses import dataclass, field
from pathlib import Path
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Type, Union
from typing import Dict, List, Optional, Tuple, Type, TYPE_CHECKING, Union

import libcst as cst
from libcst import BatchableCSTVisitor
Expand Down
2 changes: 1 addition & 1 deletion fixit/common/cli/__init__.py
Expand Up @@ -7,7 +7,7 @@
For backwards compatibility.
"""

from fixit.cli import IPCResult, LintOpts, find_files, ipc_main, map_paths
from fixit.cli import find_files, ipc_main, IPCResult, LintOpts, map_paths


__all__ = ["IPCResult", "LintOpts", "find_files", "ipc_main", "map_paths"]
2 changes: 1 addition & 1 deletion fixit/common/config.py
Expand Up @@ -23,7 +23,7 @@
from jsonschema import validate

from fixit.common.base import LintConfig
from fixit.common.utils import LintRuleCollectionT, import_distinct_rules_from_package
from fixit.common.utils import import_distinct_rules_from_package, LintRuleCollectionT


LINT_CONFIG_FILE_NAME: Path = Path(".fixit.config.yaml")
Expand Down
2 changes: 1 addition & 1 deletion fixit/common/full_repo_metadata.py
Expand Up @@ -6,7 +6,7 @@
from collections import defaultdict
from dataclasses import dataclass
from itertools import chain, islice
from typing import TYPE_CHECKING, Dict, Iterable, Mapping, Optional, Set
from typing import Dict, Iterable, Mapping, Optional, Set, TYPE_CHECKING

from libcst.metadata import FullRepoManager, TypeInferenceProvider

Expand Down
4 changes: 2 additions & 2 deletions fixit/common/generate_pyre_fixtures.py
Expand Up @@ -7,11 +7,11 @@
import json
import tempfile
from pathlib import Path
from typing import List, cast
from typing import cast, List

from libcst.metadata.type_inference_provider import (
PyreData,
_process_pyre_data,
PyreData,
run_command,
)

Expand Down
6 changes: 3 additions & 3 deletions fixit/common/testing.py
Expand Up @@ -6,19 +6,19 @@
import unittest
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Type, Union, cast
from typing import Any, Callable, cast, Dict, Mapping, Optional, Sequence, Type, Union

from libcst.metadata import MetadataWrapper

from fixit.common.base import CstLintRule
from fixit.common.generate_pyre_fixtures import get_fixture_path
from fixit.common.report import BaseLintRuleReport
from fixit.common.utils import (
_dedent,
gen_type_inference_wrapper,
InvalidTestCase,
LintRuleCollectionT,
ValidTestCase,
_dedent,
gen_type_inference_wrapper,
)
from fixit.rule_lint_engine import lint_file

Expand Down
2 changes: 1 addition & 1 deletion fixit/common/tests/test_autofix.py
Expand Up @@ -7,7 +7,7 @@

import libcst as cst
from libcst.metadata import CodePosition, MetadataWrapper
from libcst.testing.utils import UnitTest, data_provider
from libcst.testing.utils import data_provider, UnitTest

from fixit.common.autofix import LintPatch

Expand Down
2 changes: 1 addition & 1 deletion fixit/common/tests/test_full_repo_metadata.py
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path
from subprocess import TimeoutExpired
from typing import Dict, Mapping
from unittest.mock import MagicMock, call, patch
from unittest.mock import call, MagicMock, patch

from libcst.metadata import TypeInferenceProvider
from libcst.metadata.base_provider import ProviderT
Expand Down
2 changes: 1 addition & 1 deletion fixit/common/tests/test_ignores.py
Expand Up @@ -9,7 +9,7 @@
from typing import Container, Iterable, Tuple

import libcst as cst
from libcst.testing.utils import UnitTest, data_provider
from libcst.testing.utils import data_provider, UnitTest

from fixit.common.comments import CommentInfo
from fixit.common.ignores import IgnoreInfo
Expand Down
4 changes: 2 additions & 2 deletions fixit/common/tests/test_imports.py
Expand Up @@ -11,11 +11,11 @@

from fixit.common.config import get_lint_config, get_rules_from_config
from fixit.common.utils import (
DuplicateLintRuleNameError,
LintRuleNotFoundError,
dedent_with_lstrip,
DuplicateLintRuleNameError,
find_and_import_rule,
import_rule_from_package,
LintRuleNotFoundError,
)


Expand Down
4 changes: 2 additions & 2 deletions fixit/common/tests/test_insert_suppressions.py
Expand Up @@ -5,12 +5,12 @@

from typing import Iterable

from libcst.testing.utils import UnitTest, data_provider
from libcst.testing.utils import data_provider, UnitTest

from fixit.common.insert_suppressions import (
insert_suppressions,
SuppressionComment,
SuppressionCommentKind,
insert_suppressions,
)
from fixit.common.utils import dedent_with_lstrip

Expand Down
2 changes: 1 addition & 1 deletion fixit/common/tests/test_line_mapping.py
Expand Up @@ -7,7 +7,7 @@
from io import BytesIO
from typing import Mapping

from libcst.testing.utils import UnitTest, data_provider
from libcst.testing.utils import data_provider, UnitTest

from fixit.common.line_mapping import LineMappingInfo
from fixit.common.utils import dedent_with_lstrip
Expand Down
2 changes: 1 addition & 1 deletion fixit/common/tests/test_report.py
Expand Up @@ -8,7 +8,7 @@
from pathlib import Path

import libcst as cst
from libcst.testing.utils import UnitTest, data_provider
from libcst.testing.utils import data_provider, UnitTest

from fixit.common.report import AstLintRuleReport, BaseLintRuleReport, CstLintRuleReport

Expand Down
6 changes: 3 additions & 3 deletions fixit/common/tests/test_unused_suppressions.py
Expand Up @@ -7,18 +7,18 @@

import libcst as cst
from libcst.metadata import MetadataWrapper
from libcst.testing.utils import UnitTest, data_provider
from libcst.testing.utils import data_provider, UnitTest

from fixit.common.base import CstContext, CstLintRule, LintConfig
from fixit.common.comments import CommentInfo
from fixit.common.ignores import IgnoreInfo
from fixit.common.line_mapping import LineMappingInfo
from fixit.common.report import CstLintRuleReport
from fixit.common.unused_suppressions import (
_compose_new_comment,
RemoveUnusedSuppressionsRule,
UNUSED_SUPPRESSION_CODES_IN_COMMENT_MESSAGE,
UNUSED_SUPPRESSION_COMMENT_MESSAGE,
RemoveUnusedSuppressionsRule,
_compose_new_comment,
)
from fixit.common.utils import dedent_with_lstrip
from fixit.rule_lint_engine import _get_tokens, _visit_cst_rules_with_context
Expand Down
2 changes: 1 addition & 1 deletion fixit/common/unused_suppressions.py
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import Collection, List, Sequence, cast
from typing import cast, Collection, List, Sequence

import libcst as cst
from libcst.metadata import ParentNodeProvider, PositionProvider
Expand Down
2 changes: 1 addition & 1 deletion fixit/common/utils.py
Expand Up @@ -12,7 +12,7 @@
from dataclasses import dataclass
from pathlib import Path
from types import ModuleType
from typing import Dict, List, Optional, Set, Type, Union, cast
from typing import cast, Dict, List, Optional, Set, Type, Union

import libcst as cst
from libcst._add_slots import add_slots
Expand Down
2 changes: 1 addition & 1 deletion fixit/rule_lint_engine.py
Expand Up @@ -7,7 +7,7 @@
import tokenize
from dataclasses import dataclass
from pathlib import Path
from typing import Collection, List, Optional, Sequence, Type, cast
from typing import cast, Collection, List, Optional, Sequence, Type

import libcst as cst
from libcst.metadata import MetadataWrapper
Expand Down
2 changes: 1 addition & 1 deletion fixit/rules/await_async_call.py
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import Dict, Optional, Sequence, Union, cast
from typing import cast, Dict, Optional, Sequence, Union

import libcst as cst
import libcst.matchers as m
Expand Down
2 changes: 1 addition & 1 deletion fixit/rules/no_namedtuple.py
Expand Up @@ -6,7 +6,7 @@
from typing import List, Optional, Sequence, Tuple

import libcst as cst
from libcst import MaybeSentinel, ensure_type, parse_expression
from libcst import ensure_type, MaybeSentinel, parse_expression
from libcst.metadata import QualifiedName, QualifiedNameProvider, QualifiedNameSource

from fixit import CstLintRule, InvalidTestCase as Invalid, ValidTestCase as Valid
Expand Down
2 changes: 1 addition & 1 deletion fixit/rules/use_is_none_on_optional.py
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import Dict, List, Optional, Union, cast
from typing import cast, Dict, List, Optional, Union

import libcst as cst
import libcst.matchers as m
Expand Down
2 changes: 1 addition & 1 deletion fixit/tests/test_rule_lint_engine.py
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path

import libcst as cst
from libcst.testing.utils import UnitTest, data_provider
from libcst.testing.utils import data_provider, UnitTest

from fixit import rule_lint_engine
from fixit.common.base import CstLintRule, LintConfig
Expand Down
5 changes: 3 additions & 2 deletions requirements-dev.txt
@@ -1,8 +1,9 @@
black>=19.10b0
black>=21.10b0
codecov>=2.0.15
coverage>=4.5.4
git+https://github.com/jimmylai/sphinx.git@slots_type_annotation
isort>=4.3.20
ufmt==1.3
usort==1.0.0rc1
jupyter>=1.0.0
nbsphinx>=0.7.1
pyre-check==0.9.9; platform_system != "Windows"
Expand Down