Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion polyapi/deployables.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import hashlib
from pathlib import Path
from typing import TypedDict, List, Dict, Tuple, Optional, Any, Union
from typing_extensions import Required
from subprocess import check_output, CalledProcessError


Expand Down Expand Up @@ -54,7 +55,7 @@ class DeployableRecord(ParsedDeployableConfig, total=False):
gitRevision: str
fileRevision: str
file: str
types: DeployableFunctionTypes
types: Required[DeployableFunctionTypes]
typeSchemas: Dict[str, Any]
dependencies: List[str]
deployments: List[Deployment]
Expand Down
16 changes: 13 additions & 3 deletions polyapi/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import types
import sys
import re
from typing import Dict, List, Mapping, Optional, Tuple, Any
from typing import Dict, List, Mapping, Optional, Tuple, Any, Union
from typing import _TypedDictMeta as BaseTypedDict # type: ignore
from typing_extensions import _TypedDictMeta, cast # type: ignore
from stdlib_list import stdlib_list
Expand Down Expand Up @@ -390,7 +390,7 @@ def visit_AnnAssign(self, node):
deployable["config"] = _parse_dict(node.value)
self._name = deployable["config"]["name"]

def _extract_docstring_from_function(self, node: ast.FunctionDef):
def _extract_docstring_from_function(self, node: Union[ast.FunctionDef, ast.AsyncFunctionDef]):
start_lineno = (node.body[0].lineno if node.body else node.lineno) - 1
start_offset = self._line_offsets[start_lineno]
end_offset = start_offset
Expand Down Expand Up @@ -452,15 +452,19 @@ def visit_Import(self, node: ast.Import):
for name in node.names:
req = _get_req_name_if_not_in_base(name.name, pip_name_lookup)
if req:
if "dependencies" not in deployable or deployable["dependencies"] is None:
deployable["dependencies"] = []
deployable["dependencies"].append(req)

def visit_ImportFrom(self, node: ast.ImportFrom):
if node.module:
req = _get_req_name_if_not_in_base(node.module, pip_name_lookup)
if req:
if "dependencies" not in deployable or deployable["dependencies"] is None:
deployable["dependencies"] = []
deployable["dependencies"].append(req)

def visit_FunctionDef(self, node: ast.FunctionDef):
def _handle_function_def(self, node: Union[ast.FunctionDef, ast.AsyncFunctionDef]):
if node.name == self._name:
# Parse docstring which may contain param types and descriptions
self._extract_docstring_from_function(node)
Expand Down Expand Up @@ -506,6 +510,12 @@ def visit_FunctionDef(self, node: ast.FunctionDef):
else:
deployable["types"]["returns"]["type"] = "Any"

def visit_FunctionDef(self, node: ast.FunctionDef):
self._handle_function_def(node)

def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef):
self._handle_function_def(node)

def generic_visit(self, node):
if hasattr(node, 'lineno') and hasattr(node, 'col_offset'):
self._current_offset = self._line_offsets[node.lineno - 1] + node.col_offset
Expand Down
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[build-system]
requires = ["setuptools>=61.2", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "polyapi-python"
version = "0.3.12"
version = "0.3.13.dev1"
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
authors = [{ name = "Dan Fellin", email = "[email protected]" }]
dependencies = [
Expand All @@ -23,14 +24,11 @@ requires-python = ">=3.10"
[project.urls]
Homepage = "https://github.com/polyapi/polyapi-python"

[tool.setuptools]
packages = ["polyapi"]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed packages = ["polyapi"] because it conflicts with tool.setuptools.packages.find. The old file “worked” only because the packages.find table was misspelled as [tools.setuptools.packages.find], so it was ignored and the exclude list never applied. With the typo fixed, we can only choose one method; so have it using packages.find to keep the include/exclude behavior. If this is an issue we can remove packages.find and just use packages = ["polyapi"]


[tools.setuptools.packages.find]
[tool.setuptools.packages.find]
include = ["polyapi"]
exclude = ["polyapi/poly*", "polyapi/vari*", "polyapi/.config.env", "polyapi/cached_deployables*", "polyapi/deployments_revision"] # exclude the generated libraries from builds

[tool.mypy]
# for now redef errors happen sometimes, we will clean this up in the future!
disable_error_code = "no-redef,name-defined"
implicit_optional = true
implicit_optional = true