@suss/adapter-python 0.35.1 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { RequestSpellingMetadata, TypeShape, WrapperReference, BehavioralSummary } from '@suss/behavioral-ir';
1
+ import { RequestSpellingMetadata, MessageBusTechnology, TypeShape, WrapperReference, BehavioralSummary } from '@suss/behavioral-ir';
2
2
  import { Tree, Node } from 'web-tree-sitter';
3
3
  export { Node as PyNode, Tree as PyTree } from 'web-tree-sitter';
4
4
  import { Database } from '@suss/datalog';
5
- import { RedirectOption, RawCodeStructure, ExtractorOptions, TimingReport, ExtractionReport, CacheDiagnostic, DeclaredModule, KeptParses } from '@suss/extractor';
6
- import { UnwrapsByName, WhyExplained } from '@suss/resolution';
5
+ import { DeclaredEntryPoint, LibraryEnvVars, RedirectOption, RawCodeStructure, ExtractorOptions, TimingReport, ExtractionReport, CacheDiagnostic, DeclaredModule, KeptParses } from '@suss/extractor';
6
+ import { UnwrapsByName, SubclassPlace, WhyExplained } from '@suss/resolution';
7
7
 
8
8
  /**
9
9
  * Loads the Python grammar into web-tree-sitter and parses a file.
@@ -105,6 +105,14 @@ interface PythonPack {
105
105
  /** Wire protocol for the produced boundary bindings, e.g. "http". */
106
106
  protocol: string;
107
107
  discovery: PythonDiscoveryPattern[];
108
+ /**
109
+ * The functions a deploy manifest says the platform calls in a file,
110
+ * given the file's absolute path. The adapter builds the units on each
111
+ * function it finds by name, and the call walk starts there.
112
+ */
113
+ entryPoints?: (file: string) => DeclaredEntryPoint[];
114
+ /** Environment variables the library reads from its own installed code, where no walk over the project goes. */
115
+ libraryEnvVars?: LibraryEnvVars[];
108
116
  /**
109
117
  * Wrapper modules around the library that a person lists when
110
118
  * configuring the pack. The library's own module does not go here. The adapter
@@ -137,6 +145,70 @@ interface PythonPack {
137
145
  requestSpelling?: RequestSpellingMetadata;
138
146
  /** How the library's test runner collects tests, so a PRD scenario can say which test covers it. */
139
147
  tests?: PyTestCases[];
148
+ /** How the library runs a project function as a background job, and the calls that enqueue one. DESIGN.md says how each is read. */
149
+ jobQueues?: PyJobQueue[];
150
+ }
151
+ /**
152
+ * A library that runs a project's functions off a queue, such as Celery.
153
+ * A function under one of `taskDecorators` becomes a consumer unit, and a
154
+ * call that enqueues it becomes a `message-send` on the same channel.
155
+ * Every name here is one the library defines.
156
+ */
157
+ interface PyJobQueue {
158
+ /** The bus the bindings say, `celery`. */
159
+ messageBus: MessageBusTechnology;
160
+ /** The module the library's decorators and app class come from, `celery`. */
161
+ module: string;
162
+ /** Decorators that make a function a task: `shared_task`, and `task` on the app. */
163
+ taskDecorators: string[];
164
+ /** The keyword a task decorator takes the task's name under: `name`. */
165
+ nameKeyword: string;
166
+ /** The keyword a task decorator takes its queue under: `queue`. */
167
+ queueKeyword: string;
168
+ /** What the library calls a task whose decorator gives no name. */
169
+ defaultName: PyDefaultTaskName;
170
+ /** Methods on a task that enqueue it, and where each takes the task's arguments. */
171
+ enqueueMethods: PyEnqueueMethod[];
172
+ /** Methods on the app that enqueue a task by its name, `send_task`. */
173
+ sendByName?: PySendByName[];
174
+ /** The app's class, and the objects the module exports that stand for the app: `Celery`, `current_app`. */
175
+ apps: string[];
176
+ }
177
+ /**
178
+ * `modulePath` is Celery's: the dotted path of the module the function
179
+ * is written in, a dot, and the function's name.
180
+ */
181
+ type PyDefaultTaskName = "modulePath";
182
+ /** Where a method takes one of its inputs: a position, a keyword, or both. */
183
+ interface PyCallArgument {
184
+ argument?: number;
185
+ keyword?: string;
186
+ }
187
+ /**
188
+ * How an enqueue call passes the task's arguments. `spread` passes them
189
+ * as the call's own, `delay(a, b, c=1)`. `packed` passes the positional
190
+ * ones as one sequence and the keyword ones as one mapping,
191
+ * `apply_async((a, b), {"c": 1})`.
192
+ */
193
+ type PyTaskArguments = {
194
+ type: "spread";
195
+ } | {
196
+ type: "packed";
197
+ args: PyCallArgument;
198
+ kwargs: PyCallArgument;
199
+ };
200
+ interface PyEnqueueMethod {
201
+ /** The method's name, `delay`. */
202
+ method: string;
203
+ arguments: PyTaskArguments;
204
+ }
205
+ interface PySendByName {
206
+ /** The method's name, `send_task`. */
207
+ method: string;
208
+ /** Where it takes the task's name. */
209
+ name: PyCallArgument;
210
+ /** Where it takes the task's arguments. */
211
+ arguments: PyTaskArguments;
140
212
  }
141
213
  /**
142
214
  * How a test runner finds tests and what it runs around each one. Every
@@ -1033,6 +1105,12 @@ interface ReachedFunction {
1033
1105
  readonly name: string;
1034
1106
  /** `[name]` for a module function, `[Class, name]` for a method. */
1035
1107
  readonly exportPath: string[];
1108
+ /** The subclass the method runs on, when the call reached it through a class that inherits it. Calls on `self` or `cls` then resolve against that class. */
1109
+ readonly receiverClass?: PythonSubclass;
1110
+ }
1111
+ /** A class that inherits a method: its name, the file that declares it, and its key in the value facts. */
1112
+ interface PythonSubclass extends SubclassPlace {
1113
+ readonly key: string;
1036
1114
  }
1037
1115
 
1038
1116
  /**
@@ -1521,4 +1599,4 @@ declare function pythonImportEvidence(options: PythonImportEvidenceOptions): Pro
1521
1599
  */
1522
1600
  declare const ADAPTER_VERSION = "0.1.0";
1523
1601
 
1524
- export { ADAPTER_VERSION, type AnnotationContext, type Binding, type BoundPythonFile, type DecoratedClassRoute, type DecoratedFunctionRoute, type DecoratorArg, type DecoratorClassification, type DiscoveryOptions, type ExtractPythonOptions, type ExtractPythonResult, type FileFactsOptions, type KeptPythonParses, type ModuleBinding, type ModuleResolution, type ModuleResolverOptions, type MountObjectCarrier, type MountObjectPrefix, type MountPrefixEffect, type NoValuePrefix, type ParameterSource, type PathRepeatedSlashes, type PrefixTrailingSlash, type PyModelEntryFunction, type PyModelEntryMethod, type PyModelQueries, type PyStatusCall, type PyTestCases, type PyTestMocks, type PyTestSetUp, type PythonDiscoveryPattern, type PythonImportEvidence, type PythonImportEvidenceOptions, type PythonImportSite, type PythonPack, type PythonSourceRoots, type PythonValueHandle, PythonWhySession, type PythonWhySessionOptions, type RawSqlPattern, type RelativeModuleSpec, type RequestObject, type RouteConventions, type RoutePrefixResolution, type RouterComposition, type RouterIndex, type Scope, type ScopeKind, type SqlCallArgument, type SqlClientHandoff, type SqlClientPattern, type SqlStatementCall, type SqlTableCall, type StoragePattern, type TomlFileRead, type TomlTable, type UnreadManifest, annotationToShape, bindModule, buildRouterIndex, classifyDecorator, containedValues, discoverUnits, emitModuleImportFacts, emitValueFacts, extractPythonProject, factsForFile, findPythonFiles, keptPythonParses, nameKeyIn, nodeId, objectReturnedBy, parsePython, parsePythonAhead, parsePythonSync, preloadPythonGrammar, pythonImportEvidence, pythonSourceRoots, readKey, readTomlFile, resolveAbsoluteModule, resolveCalls, resolveModule, resolveName, resolveRelativeModule, shapeFromName, tableAt };
1602
+ export { ADAPTER_VERSION, type AnnotationContext, type Binding, type BoundPythonFile, type DecoratedClassRoute, type DecoratedFunctionRoute, type DecoratorArg, type DecoratorClassification, type DiscoveryOptions, type ExtractPythonOptions, type ExtractPythonResult, type FileFactsOptions, type KeptPythonParses, type ModuleBinding, type ModuleResolution, type ModuleResolverOptions, type MountObjectCarrier, type MountObjectPrefix, type MountPrefixEffect, type NoValuePrefix, type ParameterSource, type PathRepeatedSlashes, type PrefixTrailingSlash, type PyCallArgument, type PyDefaultTaskName, type PyEnqueueMethod, type PyJobQueue, type PyModelEntryFunction, type PyModelEntryMethod, type PyModelQueries, type PySendByName, type PyStatusCall, type PyTaskArguments, type PyTestCases, type PyTestMocks, type PyTestSetUp, type PythonDiscoveryPattern, type PythonImportEvidence, type PythonImportEvidenceOptions, type PythonImportSite, type PythonPack, type PythonSourceRoots, type PythonValueHandle, PythonWhySession, type PythonWhySessionOptions, type RawSqlPattern, type RelativeModuleSpec, type RequestObject, type RouteConventions, type RoutePrefixResolution, type RouterComposition, type RouterIndex, type Scope, type ScopeKind, type SqlCallArgument, type SqlClientHandoff, type SqlClientPattern, type SqlStatementCall, type SqlTableCall, type StoragePattern, type TomlFileRead, type TomlTable, type UnreadManifest, annotationToShape, bindModule, buildRouterIndex, classifyDecorator, containedValues, discoverUnits, emitModuleImportFacts, emitValueFacts, extractPythonProject, factsForFile, findPythonFiles, keptPythonParses, nameKeyIn, nodeId, objectReturnedBy, parsePython, parsePythonAhead, parsePythonSync, preloadPythonGrammar, pythonImportEvidence, pythonSourceRoots, readKey, readTomlFile, resolveAbsoluteModule, resolveCalls, resolveModule, resolveName, resolveRelativeModule, shapeFromName, tableAt };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { RequestSpellingMetadata, TypeShape, WrapperReference, BehavioralSummary } from '@suss/behavioral-ir';
1
+ import { RequestSpellingMetadata, MessageBusTechnology, TypeShape, WrapperReference, BehavioralSummary } from '@suss/behavioral-ir';
2
2
  import { Tree, Node } from 'web-tree-sitter';
3
3
  export { Node as PyNode, Tree as PyTree } from 'web-tree-sitter';
4
4
  import { Database } from '@suss/datalog';
5
- import { RedirectOption, RawCodeStructure, ExtractorOptions, TimingReport, ExtractionReport, CacheDiagnostic, DeclaredModule, KeptParses } from '@suss/extractor';
6
- import { UnwrapsByName, WhyExplained } from '@suss/resolution';
5
+ import { DeclaredEntryPoint, LibraryEnvVars, RedirectOption, RawCodeStructure, ExtractorOptions, TimingReport, ExtractionReport, CacheDiagnostic, DeclaredModule, KeptParses } from '@suss/extractor';
6
+ import { UnwrapsByName, SubclassPlace, WhyExplained } from '@suss/resolution';
7
7
 
8
8
  /**
9
9
  * Loads the Python grammar into web-tree-sitter and parses a file.
@@ -105,6 +105,14 @@ interface PythonPack {
105
105
  /** Wire protocol for the produced boundary bindings, e.g. "http". */
106
106
  protocol: string;
107
107
  discovery: PythonDiscoveryPattern[];
108
+ /**
109
+ * The functions a deploy manifest says the platform calls in a file,
110
+ * given the file's absolute path. The adapter builds the units on each
111
+ * function it finds by name, and the call walk starts there.
112
+ */
113
+ entryPoints?: (file: string) => DeclaredEntryPoint[];
114
+ /** Environment variables the library reads from its own installed code, where no walk over the project goes. */
115
+ libraryEnvVars?: LibraryEnvVars[];
108
116
  /**
109
117
  * Wrapper modules around the library that a person lists when
110
118
  * configuring the pack. The library's own module does not go here. The adapter
@@ -137,6 +145,70 @@ interface PythonPack {
137
145
  requestSpelling?: RequestSpellingMetadata;
138
146
  /** How the library's test runner collects tests, so a PRD scenario can say which test covers it. */
139
147
  tests?: PyTestCases[];
148
+ /** How the library runs a project function as a background job, and the calls that enqueue one. DESIGN.md says how each is read. */
149
+ jobQueues?: PyJobQueue[];
150
+ }
151
+ /**
152
+ * A library that runs a project's functions off a queue, such as Celery.
153
+ * A function under one of `taskDecorators` becomes a consumer unit, and a
154
+ * call that enqueues it becomes a `message-send` on the same channel.
155
+ * Every name here is one the library defines.
156
+ */
157
+ interface PyJobQueue {
158
+ /** The bus the bindings say, `celery`. */
159
+ messageBus: MessageBusTechnology;
160
+ /** The module the library's decorators and app class come from, `celery`. */
161
+ module: string;
162
+ /** Decorators that make a function a task: `shared_task`, and `task` on the app. */
163
+ taskDecorators: string[];
164
+ /** The keyword a task decorator takes the task's name under: `name`. */
165
+ nameKeyword: string;
166
+ /** The keyword a task decorator takes its queue under: `queue`. */
167
+ queueKeyword: string;
168
+ /** What the library calls a task whose decorator gives no name. */
169
+ defaultName: PyDefaultTaskName;
170
+ /** Methods on a task that enqueue it, and where each takes the task's arguments. */
171
+ enqueueMethods: PyEnqueueMethod[];
172
+ /** Methods on the app that enqueue a task by its name, `send_task`. */
173
+ sendByName?: PySendByName[];
174
+ /** The app's class, and the objects the module exports that stand for the app: `Celery`, `current_app`. */
175
+ apps: string[];
176
+ }
177
+ /**
178
+ * `modulePath` is Celery's: the dotted path of the module the function
179
+ * is written in, a dot, and the function's name.
180
+ */
181
+ type PyDefaultTaskName = "modulePath";
182
+ /** Where a method takes one of its inputs: a position, a keyword, or both. */
183
+ interface PyCallArgument {
184
+ argument?: number;
185
+ keyword?: string;
186
+ }
187
+ /**
188
+ * How an enqueue call passes the task's arguments. `spread` passes them
189
+ * as the call's own, `delay(a, b, c=1)`. `packed` passes the positional
190
+ * ones as one sequence and the keyword ones as one mapping,
191
+ * `apply_async((a, b), {"c": 1})`.
192
+ */
193
+ type PyTaskArguments = {
194
+ type: "spread";
195
+ } | {
196
+ type: "packed";
197
+ args: PyCallArgument;
198
+ kwargs: PyCallArgument;
199
+ };
200
+ interface PyEnqueueMethod {
201
+ /** The method's name, `delay`. */
202
+ method: string;
203
+ arguments: PyTaskArguments;
204
+ }
205
+ interface PySendByName {
206
+ /** The method's name, `send_task`. */
207
+ method: string;
208
+ /** Where it takes the task's name. */
209
+ name: PyCallArgument;
210
+ /** Where it takes the task's arguments. */
211
+ arguments: PyTaskArguments;
140
212
  }
141
213
  /**
142
214
  * How a test runner finds tests and what it runs around each one. Every
@@ -1033,6 +1105,12 @@ interface ReachedFunction {
1033
1105
  readonly name: string;
1034
1106
  /** `[name]` for a module function, `[Class, name]` for a method. */
1035
1107
  readonly exportPath: string[];
1108
+ /** The subclass the method runs on, when the call reached it through a class that inherits it. Calls on `self` or `cls` then resolve against that class. */
1109
+ readonly receiverClass?: PythonSubclass;
1110
+ }
1111
+ /** A class that inherits a method: its name, the file that declares it, and its key in the value facts. */
1112
+ interface PythonSubclass extends SubclassPlace {
1113
+ readonly key: string;
1036
1114
  }
1037
1115
 
1038
1116
  /**
@@ -1521,4 +1599,4 @@ declare function pythonImportEvidence(options: PythonImportEvidenceOptions): Pro
1521
1599
  */
1522
1600
  declare const ADAPTER_VERSION = "0.1.0";
1523
1601
 
1524
- export { ADAPTER_VERSION, type AnnotationContext, type Binding, type BoundPythonFile, type DecoratedClassRoute, type DecoratedFunctionRoute, type DecoratorArg, type DecoratorClassification, type DiscoveryOptions, type ExtractPythonOptions, type ExtractPythonResult, type FileFactsOptions, type KeptPythonParses, type ModuleBinding, type ModuleResolution, type ModuleResolverOptions, type MountObjectCarrier, type MountObjectPrefix, type MountPrefixEffect, type NoValuePrefix, type ParameterSource, type PathRepeatedSlashes, type PrefixTrailingSlash, type PyModelEntryFunction, type PyModelEntryMethod, type PyModelQueries, type PyStatusCall, type PyTestCases, type PyTestMocks, type PyTestSetUp, type PythonDiscoveryPattern, type PythonImportEvidence, type PythonImportEvidenceOptions, type PythonImportSite, type PythonPack, type PythonSourceRoots, type PythonValueHandle, PythonWhySession, type PythonWhySessionOptions, type RawSqlPattern, type RelativeModuleSpec, type RequestObject, type RouteConventions, type RoutePrefixResolution, type RouterComposition, type RouterIndex, type Scope, type ScopeKind, type SqlCallArgument, type SqlClientHandoff, type SqlClientPattern, type SqlStatementCall, type SqlTableCall, type StoragePattern, type TomlFileRead, type TomlTable, type UnreadManifest, annotationToShape, bindModule, buildRouterIndex, classifyDecorator, containedValues, discoverUnits, emitModuleImportFacts, emitValueFacts, extractPythonProject, factsForFile, findPythonFiles, keptPythonParses, nameKeyIn, nodeId, objectReturnedBy, parsePython, parsePythonAhead, parsePythonSync, preloadPythonGrammar, pythonImportEvidence, pythonSourceRoots, readKey, readTomlFile, resolveAbsoluteModule, resolveCalls, resolveModule, resolveName, resolveRelativeModule, shapeFromName, tableAt };
1602
+ export { ADAPTER_VERSION, type AnnotationContext, type Binding, type BoundPythonFile, type DecoratedClassRoute, type DecoratedFunctionRoute, type DecoratorArg, type DecoratorClassification, type DiscoveryOptions, type ExtractPythonOptions, type ExtractPythonResult, type FileFactsOptions, type KeptPythonParses, type ModuleBinding, type ModuleResolution, type ModuleResolverOptions, type MountObjectCarrier, type MountObjectPrefix, type MountPrefixEffect, type NoValuePrefix, type ParameterSource, type PathRepeatedSlashes, type PrefixTrailingSlash, type PyCallArgument, type PyDefaultTaskName, type PyEnqueueMethod, type PyJobQueue, type PyModelEntryFunction, type PyModelEntryMethod, type PyModelQueries, type PySendByName, type PyStatusCall, type PyTaskArguments, type PyTestCases, type PyTestMocks, type PyTestSetUp, type PythonDiscoveryPattern, type PythonImportEvidence, type PythonImportEvidenceOptions, type PythonImportSite, type PythonPack, type PythonSourceRoots, type PythonValueHandle, PythonWhySession, type PythonWhySessionOptions, type RawSqlPattern, type RelativeModuleSpec, type RequestObject, type RouteConventions, type RoutePrefixResolution, type RouterComposition, type RouterIndex, type Scope, type ScopeKind, type SqlCallArgument, type SqlClientHandoff, type SqlClientPattern, type SqlStatementCall, type SqlTableCall, type StoragePattern, type TomlFileRead, type TomlTable, type UnreadManifest, annotationToShape, bindModule, buildRouterIndex, classifyDecorator, containedValues, discoverUnits, emitModuleImportFacts, emitValueFacts, extractPythonProject, factsForFile, findPythonFiles, keptPythonParses, nameKeyIn, nodeId, objectReturnedBy, parsePython, parsePythonAhead, parsePythonSync, preloadPythonGrammar, pythonImportEvidence, pythonSourceRoots, readKey, readTomlFile, resolveAbsoluteModule, resolveCalls, resolveModule, resolveName, resolveRelativeModule, shapeFromName, tableAt };