@@ -1276,11 +1276,12 @@ def _import(
12761276 )
12771277 return None
12781278
1279- if self .source == source :
1279+ if same_file ( self .source , source ) :
12801280 if parent_import :
12811281 self .append_diagnostics (
12821282 range = parent_import .range ,
1283- message = "Possible circular import." ,
1283+ message = f"Possible circular import detected, Resource file'{ Path (self .source ).name } ' "
1284+ "might reference itself directly or through other resource files" ,
12841285 severity = DiagnosticSeverity .INFORMATION ,
12851286 source = DIAGNOSTICS_SOURCE_NAME ,
12861287 related_information = (
@@ -1298,6 +1299,15 @@ def _import(
12981299 ),
12991300 code = Error .POSSIBLE_CIRCULAR_IMPORT ,
13001301 )
1302+ else :
1303+ self .append_diagnostics (
1304+ range = value .range ,
1305+ message = f"Circular import detected, Resource file '{ Path (source ).name } ' "
1306+ "is importing itself" ,
1307+ severity = DiagnosticSeverity .INFORMATION ,
1308+ source = DIAGNOSTICS_SOURCE_NAME ,
1309+ code = Error .CIRCULAR_IMPORT ,
1310+ )
13011311 else :
13021312 result = self ._get_resource_entry (
13031313 value .name ,
@@ -1545,7 +1555,14 @@ def _import_imports(
15451555 (
15461556 e
15471557 for e in self ._variables_imports .values ()
1548- if e .library_doc .source == entry .library_doc .source
1558+ if (
1559+ (
1560+ e .library_doc .source is not None
1561+ and entry .library_doc .source is not None
1562+ and same_file (e .library_doc .source , entry .library_doc .source )
1563+ )
1564+ or (e .library_doc .source is None and entry .library_doc .source is None )
1565+ )
15491566 and e .alias == entry .alias
15501567 and e .args == entry .args
15511568 ),
@@ -1610,7 +1627,14 @@ def _import_imports(
16101627 (
16111628 e
16121629 for e in self ._libraries .values ()
1613- if e .library_doc .source == entry .library_doc .source
1630+ if (
1631+ (
1632+ e .library_doc .source is not None
1633+ and entry .library_doc .source is not None
1634+ and same_file (e .library_doc .source , entry .library_doc .source )
1635+ )
1636+ or (e .library_doc .source is None and entry .library_doc .source is None )
1637+ )
16141638 and e .library_doc .member_name == entry .library_doc .member_name
16151639 and e .alias == entry .alias
16161640 and e .args == entry .args
0 commit comments