Skip to content

Commit ba6b5ad

Browse files
yileicopybara-github
authored andcommitted
Export the non harmful g-import-not-at-top pylint pragmas.
PiperOrigin-RevId: 525272674 Change-Id: I4308a1f615693655818f95e2a413f38eebb3d872
1 parent ab8d6c4 commit ba6b5ad

File tree

11 files changed

+20
-7
lines changed

11 files changed

+20
-7
lines changed

absl/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ def _run_main(main, argv):
238238
elif FLAGS.run_with_profiling or FLAGS.profile_file:
239239
# Avoid import overhead since most apps (including performance-sensitive
240240
# ones) won't be run with profiling.
241+
# pylint: disable=g-import-not-at-top
241242
import atexit
242243
if FLAGS.use_cprofile_for_profiling:
243244
import cProfile as profile

absl/command_name.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def set_kernel_process_name(name):
4747
proc_comm.write(name[:15])
4848
except EnvironmentError:
4949
try:
50-
import ctypes
50+
import ctypes # pylint: disable=g-import-not-at-top
5151
except ImportError:
5252
return # No ctypes.
5353
try:

absl/flags/_argument_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def __init__(self, enum_class, case_sensitive=True):
386386
"""
387387
# Users must have an Enum class defined before using EnumClass flag.
388388
# Therefore this dependency is guaranteed.
389-
import enum
389+
import enum # pylint: disable=g-import-not-at-top
390390

391391
if not issubclass(enum_class, enum.Enum):
392392
raise TypeError('{} is not a subclass of Enum.'.format(enum_class))

absl/flags/_defines.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from absl.flags import _helpers
2828
from absl.flags import _validators
2929

30+
# pylint: disable=g-import-not-at-top
3031
# pylint: disable=unused-import
3132
try:
3233
from typing import Text, List, Any
@@ -37,6 +38,7 @@
3738
import enum
3839
except ImportError:
3940
pass
41+
# pylint: enable=g-import-not-at-top
4042
# pylint: enable=unused-import
4143

4244
_helpers.disclaim_module_ids.add(id(sys.modules[__name__]))

absl/flags/_helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import struct
2121
import sys
2222
import textwrap
23+
# pylint: disable=g-import-not-at-top
2324
try:
2425
import fcntl
2526
except ImportError:
@@ -29,6 +30,7 @@
2930
import termios
3031
except ImportError:
3132
termios = None
33+
# pylint: enable=g-import-not-at-top
3234

3335

3436
_DEFAULT_HELP_WIDTH = 80 # Default width of help output.

absl/flags/tests/flags_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ def args_list():
993993
# to be raised.
994994
try:
995995
sys.modules.pop('absl.flags.tests.module_baz')
996-
import absl.flags.tests.module_baz
996+
import absl.flags.tests.module_baz # pylint: disable=g-import-not-at-top
997997
del absl
998998
except flags.DuplicateFlagError:
999999
raise AssertionError('Module reimport caused flag duplication error')

absl/logging/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@
9797
from absl import flags
9898
from absl.logging import converter
9999

100+
# pylint: disable=g-import-not-at-top
100101
try:
101102
from typing import NoReturn
102103
except ImportError:
103104
pass
104105

106+
# pylint: enable=g-import-not-at-top
105107

106108
FLAGS = flags.FLAGS
107109

absl/logging/tests/verbosity_flag_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
'logging.root level should be changed to ERROR, but found {}'.format(
2828
logging.root.getEffectiveLevel()))
2929

30+
# pylint: disable=g-import-not-at-top
3031
from absl import flags
3132
from absl import logging as _ # pylint: disable=unused-import
3233
from absl.testing import absltest
34+
# pylint: enable=g-import-not-at-top
3335

3436
FLAGS = flags.FLAGS
3537

absl/testing/absltest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,19 @@
4747
# The faulthandler module isn't always available, and pytype doesn't
4848
# understand that we're catching ImportError, so suppress the error.
4949
# pytype: disable=import-error
50-
import faulthandler
50+
import faulthandler # pylint: disable=g-import-not-at-top
5151
# pytype: enable=import-error
5252
except ImportError:
5353
# We use faulthandler if it is available.
5454
faulthandler = None
5555

56-
from absl import app
56+
from absl import app # pylint: disable=g-import-not-at-top
5757
from absl import flags
5858
from absl import logging
5959
from absl.testing import _pretty_print_reporter
6060
from absl.testing import xml_reporter
6161

62+
# pylint: disable=g-import-not-at-top
6263
# Make typing an optional import to avoid it being a required dependency
6364
# in Python 2. Type checkers will still understand the imports.
6465
try:
@@ -79,6 +80,7 @@
7980
_OutcomeType = unittest.case._Outcome # pytype: disable=module-attr
8081

8182

83+
# pylint: enable=g-import-not-at-top
8284

8385
# Re-export a bunch of unittest functions we support so that people don't
8486
# have to import unittest to get them

absl/tests/app_test_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import sys
1919

2020
try:
21-
import faulthandler
21+
import faulthandler # pylint: disable=g-import-not-at-top
2222
except ImportError:
2323
faulthandler = None
2424

25-
from absl import app
25+
from absl import app # pylint: disable=g-import-not-at-top
2626
from absl import flags
2727

2828
FLAGS = flags.FLAGS

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
import os
1818
import sys
1919

20+
# pylint: disable=g-import-not-at-top
2021
try:
2122
import setuptools
2223
except ImportError:
2324
from ez_setup import use_setuptools
2425
use_setuptools()
2526
import setuptools
27+
# pylint: enable=g-import-not-at-top
2628

2729
if sys.version_info < (3, 7):
2830
raise RuntimeError('Python version 3.7+ is required.')

0 commit comments

Comments
 (0)