Skip to content

Commit b239151

Browse files
authored
feat: initial code release (#2)
* feat: migrate to github * chore: stop using |= * refactor: change versioning order * refactor: raise the exception instead of catching it * fix: bad imports with src layout * fix(framework): use older hints api to keep python3.8 compat * chore: disable locally mypy because of issue with not-required * fix(examples): change hints location * chore: run mypy in strict mode * fix: small error in code found by pylance * chore: rename project with dashes * chore: refrasing and spacing mistakes * chore(test): format dict in test * chore(ci): remove reporting * docs: update emoji in readme reach-us for consistency accross repo * refactor: rename folders * refactor: add dunder to _format_request_context * docs: remove unecessary emoji
1 parent ec0274c commit b239151

File tree

22 files changed

+557
-59
lines changed

22 files changed

+557
-59
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ Keep in mind only the **pull request title** will be used as the commit message
7979

8080
See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
8181

82-
Thank you for reading through all of this, if you have any questions feel free to [reach us](../README.md#💜-reach-us)!
82+
Thank you for reading through all of this, if you have any questions feel free to [reach us](../README.md#reach-us)!

.github/workflows/pytest.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
test:
1515
strategy:
1616
matrix:
17-
python-version: ['3.8', '3.9', '3.10', '3.11']
17+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1818

1919
runs-on: ubuntu-22.04
2020
steps:
@@ -39,14 +39,4 @@ jobs:
3939
4040
- name: Test with pytest
4141
working-directory: tests
42-
run: poetry run pytest --junitxml=junit/test-results-${{ matrix.python-version
43-
}}.xml
44-
45-
- name: Upload pytest report
46-
uses: actions/upload-artifact@v3
47-
with:
48-
name: pytest-results-${{ matrix.python-version }}
49-
path: tests/junit/test-results-${{ matrix.python-version }}.xml
50-
retention-days: 3
51-
# Use always() to always run this step to publish test results when there are test failures
52-
if: ${{ always() }}
42+
run: poetry run pytest

.github/workflows/report.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ repos:
5151
additional_dependencies:
5252
- tomli # for reading config from pyproject.toml
5353
- repo: https://github.com/pre-commit/mirrors-mypy
54-
rev: v1.0.0
54+
rev: v1.0.1
5555
hooks:
5656
- id: mypy
57+
exclude: "^tests/" # See: https://github.com/pre-commit/mirrors-mypy/issues/1
58+
args: [--ignore-missing-imports] # Needed because pre-commit runs mypy in a venv
5759
additional_dependencies:
5860
- typing_extensions
59-
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
60-
rev: v1.0.6
61+
- repo: https://github.com/PyCQA/bandit
62+
rev: 1.7.4
6163
hooks:
62-
- id: python-bandit-vulnerability-check
64+
- id: bandit
6365
args: [--skip, B101, --recursive, clumper]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Serverless Functions Python 💜
22

3-
This repo contains utilities for testing your Python functions for Scaleway Serverless Functions.
3+
This repo contains utilities for testing your Python handlers for Scaleway Serverless Functions.
44

55
## ⚙️ Quick Start
66

@@ -59,7 +59,7 @@ We welcome all contributions to our open-source projects, please see our [contri
5959

6060
Do not hesitate to raise issues and pull requests we will have a look at them.
6161

62-
## 💜 Reach Us
62+
## 📭 Reach Us
6363

6464
We love feedback. Feel free to:
6565

examples/mirror.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
from typing import TYPE_CHECKING
33

44
if TYPE_CHECKING:
5-
from serverless_functions_python import Context, Event, Response
5+
# Doing a conditional import avoids the need to install the library
6+
# when deploying the function
7+
from scaleway_functions_python.framework.v1.hints import Context, Event, Response
68

79

810
def handler(event: "Event", context: "Context") -> "Response":
@@ -18,6 +20,6 @@ def handler(event: "Event", context: "Context") -> "Response":
1820

1921

2022
if __name__ == "__main__":
21-
from serverless_functions_python import serve_handler_locally
23+
from scaleway_functions_python import local
2224

23-
serve_handler_locally(handler)
25+
local.serve_handler(handler)

pyproject.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
2-
name = "serverless-functions-python"
2+
name = "scaleway-functions-python"
33
version = "0.1.0"
4-
description = "Framework to provide a good developer experience when writing Serverless Functions in Python."
4+
description = "Utilities for testing your Python handlers for Scaleway Serverless Functions."
55
authors = ["Scaleway Serverless Team <opensource@scaleway.com>"]
66

77
readme = "README.md"
@@ -27,10 +27,6 @@ classifiers = [
2727
"Programming Language :: Python :: 3.11",
2828
]
2929

30-
packages = [
31-
{ include = "framework", from = "src" },
32-
{ include = "testing", from = "src" },
33-
]
3430
include = ["CHANGELOG.md"]
3531

3632
[tool.poetry.dependencies]
@@ -56,7 +52,6 @@ requires = ["poetry-core"]
5652
build-backend = "poetry.core.masonry.api"
5753

5854
[tool.pytest.ini_options]
59-
pythonpath = ["src"]
6055
testpaths = ["tests"]
6156

6257
[tool.pylint]
@@ -65,15 +60,22 @@ disable = "missing-module-docstring"
6560
# Commented Black formatted code.
6661
max-line-length = 89
6762
# Short and common names. e is commonly used for exceptions.
68-
good-names = "i,fp,e"
63+
good-names = "i,e"
6964

7065
[tool.pylint-per-file-ignores]
71-
# Redfined outer name is for pytest fixtures
66+
# Import aliases are prefered over unused imports or __all__
67+
"__init__.py" = "useless-import-alias"
68+
# Redefined outer name is for pytest fixtures
7269
"/tests/" = "missing-class-docstring,missing-function-docstring,protected-access,redefined-outer-name"
7370

7471
[tool.isort]
7572
profile = "black"
7673

74+
[tool.mypy]
75+
python_version = "3.8"
76+
strict = true
77+
exclude = "tests"
78+
7779
[tool.pydocstyle]
7880
# Compatible with Sphinx
7981
convention = "google"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import local as local
2+
from .framework import v1 as v1
3+
from .local.serving import serve_handler as serve_handler
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import v1 as v1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import hints as hints

0 commit comments

Comments
 (0)