Skip to content

Commit

Permalink
[typing] enable Pyre strict mode by default
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmylai committed Jun 13, 2020
1 parent cc7bb9d commit d155516
Show file tree
Hide file tree
Showing 223 changed files with 31 additions and 212 deletions.
3 changes: 2 additions & 1 deletion .circleci/.pyre_configuration
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
],
"exclude": [
".*/\\.tox/.*"
]
],
"strict": true
}
1 change: 1 addition & 0 deletions .pyre_configuration.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
"exclude": [
".*/\\.tox/.*"
]
"strict": true
}
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-unsafe

# -*- coding: utf-8 -*-
#
Expand Down
1 change: 0 additions & 1 deletion libcst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from libcst._batched_visitor import BatchableCSTVisitor, visit_batched
from libcst._exceptions import MetadataException, ParserSyntaxError
from libcst._maybe_sentinel import MaybeSentinel
Expand Down
1 change: 0 additions & 1 deletion libcst/_add_slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# https://github.com/ericvsmith/dataclasses/blob/ae712dd993420d43444f188f452/LICENSE.txt
# https://github.com/ericvsmith/dataclasses/blob/ae712dd993420d43444f/dataclass_tools.py

# pyre-strict
import dataclasses
from typing import Any, Mapping, Type, TypeVar

Expand Down
1 change: 0 additions & 1 deletion libcst/_batched_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
import inspect
from typing import (
TYPE_CHECKING,
Expand Down
1 change: 0 additions & 1 deletion libcst/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from enum import Enum, auto
from typing import Any, Callable, Iterable, Optional, Sequence, Tuple, Union

Expand Down
1 change: 0 additions & 1 deletion libcst/_maybe_sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from enum import Enum, auto


Expand Down
1 change: 0 additions & 1 deletion libcst/_metadata_dependent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
# pyre-strict
import inspect
from abc import ABC
from contextlib import contextmanager
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict

"""
This package contains CSTNode and all of the subclasses needed to express Python's full
Expand Down
1 change: 1 addition & 0 deletions libcst/_nodes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ def __repr__(self) -> str:
return "\n".join(lines)

@classmethod
# pyre-fixme[3]: Return annotation cannot be `Any`.
def field(cls, *args: object, **kwargs: object) -> Any:
"""
A helper that allows us to easily use CSTNodes in dataclass constructor
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/deep_equals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
"""
Provides the implementation of `CSTNode.deep_equals`.
"""
Expand Down
4 changes: 3 additions & 1 deletion libcst/_nodes/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict

import re
from abc import ABC, abstractmethod
Expand Down Expand Up @@ -427,6 +426,7 @@ def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "Integer":

def _validate(self) -> None:
super(Integer, self)._validate()
# pyre-fixme[16]: Module `tokenize` has no attribute `Intnumber`.
if not re.fullmatch(INTNUMBER_RE, self.value):
raise CSTValidationError("Number is not a valid integer.")

Expand Down Expand Up @@ -465,6 +465,7 @@ def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "Float":

def _validate(self) -> None:
super(Float, self)._validate()
# pyre-fixme[16]: Module `tokenize` has no attribute `Floatnumber`.
if not re.fullmatch(FLOATNUMBER_RE, self.value):
raise CSTValidationError("Number is not a valid float.")

Expand Down Expand Up @@ -502,6 +503,7 @@ def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "Imaginary":

def _validate(self) -> None:
super(Imaginary, self)._validate()
# pyre-fixme[16]: Module `tokenize` has no attribute `Imagnumber`.
if not re.fullmatch(IMAGNUMBER_RE, self.value):
raise CSTValidationError("Number is not a valid imaginary.")

Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict

from contextlib import contextmanager
from dataclasses import dataclass, field
Expand Down
1 change: 1 addition & 0 deletions libcst/_nodes/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def _visit_and_replace_children(self, visitor: CSTVisitorT) -> "Module":
has_trailing_newline=self.has_trailing_newline,
)

# pyre-fixme[14]: `visit` overrides method defined in `CSTNode` inconsistently.
def visit(self: _ModuleSelfT, visitor: CSTVisitorT) -> _ModuleSelfT:
"""
Returns the result of running a visitor over this module.
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Tuple
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
import dataclasses
from contextlib import ExitStack
from dataclasses import dataclass
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict

from typing import Any

Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict

from typing import Any

Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_await.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_binary_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_boolean_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any, Callable

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Callable

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Callable, Optional

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_cst_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from textwrap import dedent
from typing import Union

Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_del.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_dict_comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict

from textwrap import dedent
from typing import Optional
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_else.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_empty_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
import libcst as cst
from libcst._nodes.tests.base import CSTNodeTest, DummyIndentedBlock
from libcst.testing.utils import data_provider
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_for.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_funcdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any, Callable

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_ifexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Callable, Optional

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_indented_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Callable, Optional

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Callable, Optional

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_leaf_small_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
import libcst as cst
from libcst._nodes.tests.base import CSTNodeTest
from libcst.testing.utils import data_provider
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any, Callable

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_matrix_multiply.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Any

import libcst as cst
Expand Down
1 change: 0 additions & 1 deletion libcst/_nodes/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict
from typing import Tuple, cast

import libcst as cst
Expand Down
Loading

0 comments on commit d155516

Please sign in to comment.