@@ -109,6 +109,15 @@ module NotExposed {
109109 fullyQualifiedToApiGraphPath ( fullyQualifiedName ) = spec .getAlreadyModeledClass ( ) .getPath ( )
110110 }
111111
112+ predicate isAllowedModule ( Module mod ) {
113+ // for now, we only want to model things in site-packages (since we know these are
114+ // libraries used by real code)
115+ mod .getFile ( ) .getAbsolutePath ( ) .matches ( "%/site-packages/%" )
116+ or
117+ // for CI testing
118+ mod .getFile ( ) .getRelativePath ( ) .matches ( "%/find_subclass_test.py" )
119+ }
120+
112121 predicate isTestCode ( AstNode ast ) {
113122 ast .getScope * ( ) instanceof TestScope
114123 or
@@ -164,7 +173,8 @@ module NotExposed {
164173 mod .declaredInAll ( importMember .getName ( ) )
165174 ) and
166175 not alreadyExplicitlyModeled ( spec , newAliasFullyQualified ) and
167- not isTestCode ( importMember )
176+ not isTestCode ( importMember ) and
177+ isAllowedModule ( mod )
168178 }
169179
170180 /** same as `newDirectAlias` predicate, but handling `from <module> import *`, considering all `<member>`, where `<module>.<member>` belongs to `spec`. */
@@ -192,7 +202,8 @@ module NotExposed {
192202 mod .declaredInAll ( relevantName )
193203 ) and
194204 not alreadyExplicitlyModeled ( spec , newAliasFullyQualified ) and
195- not isTestCode ( importStar )
205+ not isTestCode ( importStar ) and
206+ isAllowedModule ( mod )
196207 }
197208
198209 /** Holds if `classExpr` defines a new subclass that belongs to `spec`, which has the fully qualified name `newSubclassQualified`. */
@@ -205,6 +216,7 @@ module NotExposed {
205216 newSubclassQualified = mod .getName ( ) + "." + classExpr .getName ( ) and
206217 loc = classExpr .getLocation ( ) and
207218 not alreadyExplicitlyModeled ( spec , newSubclassQualified ) and
208- not isTestCode ( classExpr )
219+ not isTestCode ( classExpr ) and
220+ isAllowedModule ( mod )
209221 }
210222}
0 commit comments