Skip to content

Move option processing into mypy/options.py #3391

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
MYPY = False
if MYPY:
from typing import Deque
from mypy.options import Options

from mypy.nodes import (MypyFile, Node, ImportBase, Import, ImportFrom, ImportAll)
from mypy.semanal import FirstPass, SemanticAnalyzer, ThirdPass
Expand All @@ -37,13 +38,11 @@
from mypy import util
from mypy.fixup import fixup_module_pass_one, fixup_module_pass_two
from mypy.nodes import Expression
from mypy.options import Options
from mypy.parse import parse
from mypy.stats import dump_type_stats
from mypy.types import Type
from mypy.version import __version__


# We need to know the location of this file to load data, but
# until Python 3.4, __file__ is relative.
__file__ = os.path.realpath(__file__)
Expand Down Expand Up @@ -109,7 +108,7 @@ def is_source(self, file: MypyFile) -> bool:


def build(sources: List[BuildSource],
options: Options,
options: 'Options',
alt_lib_path: str = None,
bin_dir: str = None) -> BuildResult:
"""Analyze a program.
Expand Down Expand Up @@ -362,7 +361,7 @@ def __init__(self, data_dir: str,
ignore_prefix: str,
source_set: BuildSourceSet,
reports: Reports,
options: Options,
options: 'Options',
version_id: str) -> None:
self.start_time = time.time()
self.data_dir = data_dir
Expand Down Expand Up @@ -494,7 +493,7 @@ def module_not_found(self, path: str, line: int, id: str) -> None:
def report_file(self,
file: MypyFile,
type_map: Dict[Expression, Type],
options: Options) -> None:
options: 'Options') -> None:
if self.source_set.is_source(file):
self.reports.file(file, type_map, options)

Expand Down Expand Up @@ -1148,7 +1147,7 @@ class State:
interface_hash = "" # type: str

# Options, specialized for this file
options = None # type: Options
options = None # type: 'Options'

# Whether to ignore all errors
ignore_all = False
Expand Down
9 changes: 6 additions & 3 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@
from mypy.treetransform import TransformVisitor
from mypy.binder import ConditionalTypeBinder, get_declaration
from mypy.meet import is_overlapping_types
from mypy.options import Options

from mypy import experiments

# Can't use TYPE_CHECKING because it's not in the Python 3.5.1 stdlib
MYPY = False
if MYPY:
from mypy.options import Options

T = TypeVar('T')

Expand Down Expand Up @@ -121,13 +124,13 @@ class TypeChecker(NodeVisitor[None]):
is_typeshed_stub = False
# Should strict Optional-related errors be suppressed in this file?
suppress_none_errors = False # TODO: Get it from options instead
options = None # type: Options
options = None # type: 'Options'

# The set of all dependencies (suppressed or not) that this module accesses, either
# directly or indirectly.
module_refs = None # type: Set[str]

def __init__(self, errors: Errors, modules: Dict[str, MypyFile], options: Options,
def __init__(self, errors: Errors, modules: Dict[str, MypyFile], options: 'Options',
tree: MypyFile, path: str) -> None:
"""Construct a type checker.

Expand Down
7 changes: 5 additions & 2 deletions mypy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

from typing import Tuple, List, TypeVar, Set, Dict, Iterator, Optional

from mypy.options import Options
from mypy.version import __version__ as mypy_version

# Can't use TYPE_CHECKING because it's not in the Python 3.5.1 stdlib
MYPY = False
if MYPY:
from mypy.options import Options

T = TypeVar('T')

Expand Down Expand Up @@ -515,7 +518,7 @@ def remove_path_prefix(path: str, prefix: str) -> str:


def report_internal_error(err: Exception, file: str, line: int,
errors: Errors, options: Options) -> None:
errors: Errors, options: 'Options') -> None:
"""Report internal error and exit.

This optionally starts pdb or shows a traceback.
Expand Down
Loading