Skip to content

Commit

Permalink
Move error code into its own subpackage
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 617206722
  • Loading branch information
martindemello authored and rchen152 committed Mar 19, 2024
1 parent a4d7003 commit 1c96471
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 47 deletions.
46 changes: 9 additions & 37 deletions pytype/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ py_library(
api
DEPS
.config
.errors
.io
.load_pytd
pytype.errors.errors
)

toplevel_py_binary(
Expand Down Expand Up @@ -41,29 +41,14 @@ py_library(
DEPS
._utils
.datatypes
.errors
.file_utils
.imports_map_loader
.module_utils
pytype.errors.errors
pytype.pyc.pyc
pytype.typegraph.cfg_utils
)

py_library(
NAME
errors
SRCS
errors.py
DEPS
._utils
.debug
.error_printer
.pretty_printer
pytype.abstract.abstract
pytype.overlays.overlays
pytype.pytd.pytd
)

py_library(
NAME
load_pytd
Expand Down Expand Up @@ -102,7 +87,6 @@ py_library(
.convert
.convert_structural
.debug
.errors
.imports_map_loader
.io
.load_pytd
Expand All @@ -113,6 +97,7 @@ py_library(
.tracer_vm
.vm
pytype.directors.directors
pytype.errors.errors
)

py_library(
Expand All @@ -126,20 +111,6 @@ py_library(
pytype.typegraph.cfg
)

py_library(
NAME
error_printer
SRCS
error_printer.py
DEPS
.matcher
.pretty_printer
pytype.abstract.abstract
pytype.overlays.overlays
pytype.pytd.pytd
pytype.typegraph.cfg
)

filegroup(
NAME
test_data
Expand Down Expand Up @@ -253,13 +224,13 @@ py_library(
.attribute
.config
.convert
.errors
.load_pytd
.matcher
.output
.tracer_vm
.vm_utils
pytype.abstract.abstract
pytype.errors.errors
pytype.overlays.overlays
pytype.typegraph.cfg
pytype.typegraph.cfg_utils
Expand Down Expand Up @@ -512,8 +483,8 @@ py_test(
typegraph_metrics_test.py
DEPS
.context
.errors
.vm
pytype.errors.errors
pytype.tests.test_base
pytype.typegraph.cfg
)
Expand Down Expand Up @@ -600,9 +571,9 @@ py_test(
.compare
.config
.context
.errors
.load_pytd
pytype.abstract.abstract
pytype.errors.errors
pytype.pytd.pytd
pytype.tests.test_base
)
Expand Down Expand Up @@ -638,9 +609,9 @@ py_test(
DEPS
.config
.context
.errors
.load_pytd
pytype.abstract.abstract
pytype.errors.errors
pytype.tests.test_base
)

Expand All @@ -662,12 +633,12 @@ py_test(
.config
.constant_folding
.context
.errors
.load_pytd
.state
pytype.abstract.abstract
pytype.blocks.blocks
pytype.directors.directors
pytype.errors.errors
pytype.pyc.pyc
pytype.pytd.pytd
pytype.tests.test_base
Expand Down Expand Up @@ -776,6 +747,7 @@ add_subdirectory(abstract)
add_subdirectory(ast)
add_subdirectory(blocks)
add_subdirectory(directors)
add_subdirectory(errors)
add_subdirectory(imports)
add_subdirectory(inspect)
add_subdirectory(overlays)
Expand Down
2 changes: 1 addition & 1 deletion pytype/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from typing import List, overload

from pytype import datatypes
from pytype import errors
from pytype import file_utils
from pytype import imports_map_loader
from pytype import module_utils
from pytype import utils
from pytype.errors import errors
from pytype.pyc import compiler
from pytype.typegraph import cfg_utils

Expand Down
2 changes: 1 addition & 1 deletion pytype/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pytype import attribute
from pytype import config
from pytype import convert
from pytype import errors
from pytype import load_pytd
from pytype import matcher
from pytype import output
Expand All @@ -17,6 +16,7 @@
from pytype.abstract import abstract
from pytype.abstract import abstract_utils
from pytype.abstract import function
from pytype.errors import errors
from pytype.overlays import special_builtins
from pytype.typegraph import cfg
from pytype.typegraph import cfg_utils
Expand Down
2 changes: 1 addition & 1 deletion pytype/directors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ py_test(
directors_test.py
DEPS
.directors
pytype.errors
pytype.errors.errors
)
2 changes: 1 addition & 1 deletion pytype/directors/directors_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import sys
import textwrap

from pytype import errors
from pytype.directors import directors
from pytype.errors import errors
import unittest

_TEST_FILENAME = "my_file.py"
Expand Down
38 changes: 38 additions & 0 deletions pytype/errors/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
add_package()

py_library(
NAME
errors
DEPS
._errors
.error_printer
)

py_library(
NAME
_errors
SRCS
errors.py
DEPS
.error_printer
pytype._utils
pytype.debug
pytype.pretty_printer
pytype.abstract.abstract
pytype.overlays.overlays
pytype.pytd.pytd
)

py_library(
NAME
error_printer
SRCS
error_printer.py
DEPS
pytype.matcher
pytype.pretty_printer
pytype.abstract.abstract
pytype.overlays.overlays
pytype.pytd.pytd
pytype.typegraph.cfg
)
Empty file added pytype/errors/__init__.py
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion pytype/errors.py → pytype/errors/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from typing import Callable, IO, Iterable, Optional, Sequence, TypeVar, Union

from pytype import debug
from pytype import error_printer
from pytype import pretty_printer
from pytype import utils
from pytype.abstract import abstract
from pytype.abstract import function
from pytype.errors import error_printer
from pytype.overlays import typed_dict as typed_dict_overlay
from pytype.pytd import slots

Expand Down
5 changes: 3 additions & 2 deletions pytype/errors_test.py → pytype/errors/errors_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import textwrap
from unittest import mock

from pytype import errors
from pytype import state as frame_state
from pytype.errors import errors
from pytype.platform_utils import path_utils
from pytype.tests import test_utils

Expand Down Expand Up @@ -291,8 +291,9 @@ def test_color_print_to_file(self):


class ErrorDocTest(unittest.TestCase):
dirname = path_utils.dirname
ERROR_FILE_PATH = path_utils.join(
path_utils.dirname(errors.__file__), "../docs/errors.md")
dirname(dirname(errors.__file__)), "../docs/errors.md")

def _check_and_get_documented_errors(self):
with open(self.ERROR_FILE_PATH) as f:
Expand Down
2 changes: 1 addition & 1 deletion pytype/rewrite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ py_library(
DEPS
.vm
pytype.config
pytype.errors
pytype.load_pytd
pytype.errors.errors
pytype.pytd.pytd
)

Expand Down
2 changes: 1 addition & 1 deletion pytype/rewrite/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Optional

from pytype import config
from pytype import errors
from pytype import load_pytd
from pytype.errors import errors
from pytype.pytd import pytd
from pytype.rewrite import vm as vm_lib

Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os

from pytype import errors
from pytype.errors import errors
from pytype.tests import test_base
from pytype.tests import test_utils

Expand Down

0 comments on commit 1c96471

Please sign in to comment.