Skip to content

Commit 122c799

Browse files
[mypy] Fix Item "None" of "Optional[Module]" has no attribute "__file__"
1 parent a444a61 commit 122c799

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pylint_pytest/utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,11 @@ def _is_same_module(fixtures, import_node, fixture_name):
108108
try:
109109
for fixture in fixtures[fixture_name]:
110110
for import_from in import_node.root().globals[fixture_name]:
111-
if (
112-
inspect.getmodule(fixture.func).__file__
113-
== import_from.parent.import_module(
114-
import_from.modname, False, import_from.level
115-
).file
116-
):
111+
module = inspect.getmodule(fixture.func)
112+
parent_import = import_from.parent.import_module(
113+
import_from.modname, False, import_from.level
114+
)
115+
if module is not None and module.__file__ == parent_import.file:
117116
return True
118117
except Exception: # pylint: disable=broad-except
119118
pass

0 commit comments

Comments
 (0)