summaryrefslogtreecommitdiff
path: root/tests/functional/n/no/no_name_in_module.py
blob: ef9fb03d17104f86a9c8b62d83cd78fd6c21122f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# pylint: disable=wildcard-import,unused-import,invalid-name,import-error
# pylint: disable=bare-except,broad-except,wrong-import-order,ungrouped-imports,wrong-import-position
"""check nonexistent names imported are reported"""

import collections.tutu  # [no-name-in-module]
from collections import toto  # [no-name-in-module]
toto.yo()

from xml.etree import ElementTree
ElementTree.nonexistant_function()  # [no-member]
ElementTree.another.nonexistant.function()  # [no-member]


import sys
print(sys.stdout, 'hello world')
print(sys.stdoout, 'bye bye world')  # [no-member]


import re
re.finditer('*', 'yo')

from rie import *
from re import findiiter, compiile  # [no-name-in-module,no-name-in-module]

import os
'SOMEVAR' in os.environ  # [pointless-statement]

try:
    from collections import something
except ImportError:
    something = None

try:
    from collections import anything # [no-name-in-module]
except ValueError:
    anything = None

try:
    import collections.missing
except ImportError:
    pass

try:
    import collections.missing
except ModuleNotFoundError:
    pass

try:
    import collections.indeed_missing # [no-name-in-module]
except ValueError:
    pass

try:
    import collections.emit # [no-name-in-module]
except Exception:
    pass

try:
    import collections.emit1
except ImportError:
    pass

try:
    import collections.emit1
except ModuleNotFoundError:
    pass


try:
    if something:
        import collections.emit2 # [no-name-in-module]
except Exception:
    pass

from .no_self_argument import NoSelfArgument
from .no_self_argument import lala  # [no-name-in-module]
from .no_self_argument.bla import lala1 # [no-name-in-module]

# Check ignored-modules setting
from argparse import THIS_does_not_EXIST


# This captures the original failure in https://github.com/pylint-dev/pylint/issues/6497
# only if numpy is installed. We are not installing numpy on CI (for now)
from numpy.distutils.misc_util import is_sequence
from pydantic import BaseModel