Skip to content

Commit

Permalink
feat(deducer): support working without extraPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
jianzs committed Mar 20, 2024
1 parent 11ecc36 commit 87b197f
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 58 deletions.
5 changes: 3 additions & 2 deletions apps/cli/template/python/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
HttpRequest,
HttpResponse,
)
from pluto_client.queue import CloudEvent


router = Router("router")
Expand All @@ -33,8 +34,8 @@ def store_handler(req: HttpRequest) -> HttpResponse:
)


def handle_queue_event(event_data):
data = json.loads(event_data)
def handle_queue_event(evt: CloudEvent):
data = json.loads(evt.data)
print(data)
kvstore.set(data["name"], data["message"])

Expand Down
5 changes: 0 additions & 5 deletions components/deducers/python-pyright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ export default class PyrightDeducer extends core.Deducer {
private pyrightAnalyze(entrypoints: string[]) {
const program = ProgramUtils.createProgram({
logLevel: LogLevel.Warn,
// TODO: remove the extraPaths when the package is published.
extraPaths: [
path.resolve(__dirname, "../../../../packages/base-py"),
path.resolve(__dirname, "../../../../packages/pluto-py"),
],
});

const fileUris = entrypoints.map((name) => Uri.file(name));
Expand Down
3 changes: 3 additions & 0 deletions components/deducers/python-pyright/src/program-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export function createProgram(options: CreateProgramOptions = {}) {
configOptions.typeCheckingMode = "strict";
configOptions.pythonPath = options.pythonPath ? Uri.file(options.pythonPath) : undefined;
configOptions.defaultExtraPaths = options.extraPaths?.map((p) => Uri.file(p));
// This is a workaround for a situation where pyright doesn't recognize the types if a library
// doesn't have a `py.typed` file.
configOptions.useLibraryCodeForTypes = true;

const importResolver = new ImportResolver(
serviceProvider,
Expand Down
11 changes: 4 additions & 7 deletions packages/base-py/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
.PHONY: all clean build package upload
.PHONY: all clean build publish

all: clean build package upload
all: clean build publish

clean:
rm -rf dist

build:
python3 -m build

check:
python3 -m twine check dist/*
poetry build

publish:
python3 -m twine upload dist/*
poetry publish
7 changes: 7 additions & 0 deletions packages/base-py/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 14 additions & 9 deletions packages/base-py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[project]
name = 'pluto-base'
version = '0.0.1'
description = 'The Base Library for Pluto Programming Language.'
readme = 'README.md'
[tool.poetry]
name = "pluto-base"
version = "0.0.2"
description = "The Base Library for Pluto Programming Language."
authors = ["Jade Zheng <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"
classifiers = [
'Development Status :: 1 - Planning',
'Environment :: Console',
Expand All @@ -17,6 +19,9 @@ classifiers = [
'License :: OSI Approved :: Apache Software License',
]

[project.urls]
[tool.poetry.urls]
Homepage = "https://github.com/pluto-lang/pluto"
Issues = "https://github.com/pluto-lang/pluto/issues"
Issues = "https://github.com/pluto-lang/pluto/issues"

[tool.poetry.dependencies]
python = "^3.10"
11 changes: 4 additions & 7 deletions packages/pluto-py/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
.PHONY: all clean build package upload
.PHONY: all clean build publish

all: clean build package upload
all: clean build publish

clean:
rm -rf dist

build:
python3 -m build

check:
python3 -m twine check dist/*
poetry build

publish:
python3 -m twine upload dist/*
poetry publish
17 changes: 17 additions & 0 deletions packages/pluto-py/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions packages/pluto-py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[project]
name = 'pluto-client'
version = '0.0.1'
description = 'The Client Library for Pluto Programming Language.'
readme = 'README.md'
[tool.poetry]
name = "pluto-client"
version = "0.0.3"
description = "The Client Library for Pluto Programming Language."
authors = ["Jade Zheng <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"
classifiers = [
'Development Status :: 1 - Planning',
'Environment :: Console',
Expand All @@ -17,6 +19,10 @@ classifiers = [
'License :: OSI Approved :: Apache Software License',
]

[project.urls]
[tool.poetry.urls]
Homepage = "https://github.com/pluto-lang/pluto"
Issues = "https://github.com/pluto-lang/pluto/issues"
Issues = "https://github.com/pluto-lang/pluto/issues"

[tool.poetry.dependencies]
python = "^3.10"
pluto-base = "^0.0.2"
1 change: 0 additions & 1 deletion packages/pluto-py/requirements.txt

This file was deleted.

18 changes: 0 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 87b197f

Please sign in to comment.