@@ -1276,11 +1276,12 @@ def _import(
1276
1276
)
1277
1277
return None
1278
1278
1279
- if self .source == source :
1279
+ if same_file ( self .source , source ) :
1280
1280
if parent_import :
1281
1281
self .append_diagnostics (
1282
1282
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" ,
1284
1285
severity = DiagnosticSeverity .INFORMATION ,
1285
1286
source = DIAGNOSTICS_SOURCE_NAME ,
1286
1287
related_information = (
@@ -1298,6 +1299,15 @@ def _import(
1298
1299
),
1299
1300
code = Error .POSSIBLE_CIRCULAR_IMPORT ,
1300
1301
)
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
+ )
1301
1311
else :
1302
1312
result = self ._get_resource_entry (
1303
1313
value .name ,
@@ -1545,7 +1555,14 @@ def _import_imports(
1545
1555
(
1546
1556
e
1547
1557
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
+ )
1549
1566
and e .alias == entry .alias
1550
1567
and e .args == entry .args
1551
1568
),
@@ -1610,7 +1627,14 @@ def _import_imports(
1610
1627
(
1611
1628
e
1612
1629
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
+ )
1614
1638
and e .library_doc .member_name == entry .library_doc .member_name
1615
1639
and e .alias == entry .alias
1616
1640
and e .args == entry .args
0 commit comments