GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Python: Disregard packages when looking for cyclic imports. · github/codeql@067bdf5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • python/ql/src
    • Imports
      • Cyclic.qll
    • semmle/python/objects
      • ObjectAPI.qll
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎python/ql/src/Imports/Cyclic.qll‎

Copy file name to clipboardExpand all lines: python/ql/src/Imports/Cyclic.qll
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ predicate circular_import(ModuleValue m1, ModuleValue m2) {
2121
ModuleValue stmt_imports(ImportingStmt s) {
2222
exists(string name | result.importedAs(name) and not name = "__main__" |
2323
name = s.getAnImportedModuleName() and
24-
s.getASubExpression().pointsTo(result)
24+
s.getASubExpression().pointsTo(result) and
25+
not result.isPackage()
2526
)
2627
}
2728

Collapse file

‎python/ql/src/semmle/python/objects/ObjectAPI.qll‎

Copy file name to clipboardExpand all lines: python/ql/src/semmle/python/objects/ObjectAPI.qll
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ class ModuleValue extends Value {
139139
PointsToInternal::module_imported_as(this, name)
140140
}
141141

142+
/** Whether this module is a package. */
143+
predicate isPackage() {
144+
this instanceof PackageObjectInternal
145+
}
146+
142147
}
143148

144149
module Module {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.