This repository was archived by the owner on Sep 8, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 53
Add dataclasses, sync/async, feature-parity with the js-client and tests #23
Merged
Merged
Changes from all commits
Commits
Show all changes
102 commits
Select commit
Hold shift + click to select a range
82d1d6c
feat: implement dataclasses with methods for parsing
leynier 25e223b
feat: add new types, implement to_dicts and align files with gotrue-js
leynier 1ed9754
feat: add types to API class and align implementation with gotrue-js
leynier f9ff600
chore: formatting code
leynier 930273f
feat: implement CookieOptions type
leynier a6dacaf
feat: implement AuthChangeEvent enum
leynier 8c64876
feat: implement Subscription type
leynier 044efe8
feat: implement SupportedStorage abstract storage and MemoryStorage s…
leynier 4ef1b55
feat: add CookieOptions to constructor of GoTrueApi
leynier 0a669de
feat: synchronize implementation of GoTrueClient
leynier 3400431
chore: format conftest.py
leynier ee916c2
feat: add poetry to CI action and add dependabot config file
leynier 112ce71
chore: fix name of ci test job
leynier ae0ba3f
chore: change order of strategy parameter
leynier 2ac3930
chore: fix name of ci test job
leynier da10e87
feat: implement sync/async support with httppx and unasync
leynier 42619ea
feat: add context manager support
leynier 267c62c
chore: add doc to on_auth_state_change
leynier bfc5fab
chore: format code of sync client
leynier 09f9b47
feat: add pre-commit system for check Pythonic style
leynier 8ddd940
chore: regenerate sync client
leynier 2fbcb70
chore: format code by pre-commit
leynier 6ac5334
feat: add Make rule for infra
leynier 3ab70a5
chore: add dependencies for code coverage and fix tests command
leynier fcad1af
fix: cycle of references between helpers and types
leynier 5815566
chore: separate tests rule in multiples rules
leynier 9c12bd1
fix: error in remove_item of memory storage
leynier e7ebc64
fix: remove unnecessary async to on_auth_state_change
leynier 67ecf57
test: implement provider and subscriptions tests
leynier 1ee2946
fix: ci github action
leynier 72b85b5
chore: regenerate sync client
leynier b3cba71
chore: run ci in all branches
leynier 46373e4
feat: generate tests for sync client
leynier 71a2c8f
test: ignore build_sync.py and conftest.py in Coverage
leynier 0c29382
test: implement tests for api with auto confirm disabled
leynier b8330c0
test: handle exceptions and use context manager
leynier 08d2558
test: client with sign ups disabled
leynier 4cb8330
feat: force the use of keyword parameters
leynier c407a63
test: client with auto confirm disabled
leynier c8daa2a
test: use fixtures of pytest
leynier 9870078
fix: errors in helpers and types
leynier a653408
fix: error in client update
leynier b758dba
test: client with auto confirm enabled
leynier 068fe0d
chore: add logs
leynier e575d9b
test: fix error in provider
leynier 1e65cc3
test: fix expected error message
leynier 96eb94b
test: add various Python versions to CI
leynier f70fdd2
feat: implement and use cli for unasync
leynier d1f5fc7
fix: some tipe hints
leynier 843008b
chore: split some make rules
leynier d224ec1
fix: some fixes and changes requested
leynier 3d226f5
feat: use reflection for parsing dataclasses
leynier 1859aa3
fix: remove email_change_confirm_status from User
leynier dab27ce
fix: remove Optional to user_metadata of User
leynier 73df8d7
fix: add slack adn spotify to Provider
leynier d042152
feat: add identities to User
leynier 21d7bda
fix: add Optional to identities of User
leynier eb86078
test: fix test_sign_up_the_same_user_twice_should_throw_an_error test
leynier 98e27af
fix: change ApiError by APIError
leynier 55c03a6
fix: change ApiError by APIError in docstrings
leynier b16356d
feat: use annotations from __future__
leynier 13cc086
fix: change Api by API
leynier 0ea666a
test: fix test sign up the same user twice should throw an error
leynier 3333813
feat: use asdict of dataclasses for to_dicts
leynier 3ef3707
feat: add end-of-file-fixer to .pre-commit-config.yaml
leynier 9c7a18c
feat: add --ignore-init-module-imports to .pre-commit-config.yaml
leynier 747f411
fix: .pre-commit-config.yaml format
leynier f5b0b01
chore: changes by run pre-commit
leynier 08565ac
feat: uuid4().hex instead of str(uuid4())
leynier b91e556
feat: uuid4().hex instead of str(uuid4()) in _sync client
leynier c2d37fb
fix: set prefix __ instead of _ for private methods
leynier e900c49
docs: add comment for email preferences over phone
leynier b2eb4f2
feat: unify logic of __recover_session and __recover_and_refresh
leynier 45dbc4f
chore: revert to use single _ in "private" methods
leynier 9df4927
deps: add pydantic dependency
leynier a0e4008
feat: migrate types to pydantic models
leynier 383298a
fix: use parse_obj
leynier 177b619
fix: use directly parse_obj instead of lambdas
leynier 6905d45
fix: use typing annotations
leynier eaeae46
feat: add pyupgrade pre-commit hook
leynier cb4624d
Add parse_response method to custom pydantic base model
0f3210f
Formatting
4c7003e
fix: use expires_in var for avoid typing warning
leynier 8d2c74e
chore: remove noqa comments
leynier 455794f
feat: add datetime and uuid types
leynier 72f05e2
feat: add create_user and list_users
leynier d782994
chore: add Python 3.10 to GitHub Action
leynier 2350250
fix: use str for declare Python 3.10
leynier a261996
chore: remove Python 3.10 for unknow error
leynier c60718c
feat: allow providing custom api and http client implementation
leynier 57473a2
Add python 3.10 to GH Actions fix
dreinon 64162f6
Use pydantic parse_obj_as helper method
ce47032
Use latest actions-poetry
283bd9f
docs: add description to aud field of User model
leynier ec2c893
feat: add X-Client-Info to default headers
leynier 83e8f5e
chore: update dependencies
leynier 6e501c9
fix: remove duplicate var env in docker-compose.yml
leynier 0e78b62
feat: add devcontainer.json for use github codespaces
leynier 20235fe
docs: update some info of readme
leynier ec0bdb5
Fix typo in README.md
dreinon fdc6318
chore: remove unused noqa comment
leynier 427d5d4
Switch isort mirror by isort pre-commit hook
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [run] | ||
| omit = | ||
| build_sync.py | ||
| conftest.py | ||
| tests/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.203.0/containers/python-3/.devcontainer/base.Dockerfile | ||
|
|
||
| # [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster | ||
| ARG VARIANT="3.10-bullseye" | ||
| FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} | ||
|
|
||
| # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 | ||
| ARG NODE_VERSION="none" | ||
| RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi | ||
|
|
||
| # [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. | ||
| # COPY requirements.txt /tmp/pip-tmp/ | ||
| # RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ | ||
| # && rm -rf /tmp/pip-tmp | ||
|
|
||
| # [Optional] Uncomment this section to install additional OS packages. | ||
| # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
| # && apt-get -y install --no-install-recommends <your-package-list-here> | ||
|
|
||
| # [Optional] Uncomment this line to install global node packages. | ||
| # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
| // https://github.com/microsoft/vscode-dev-containers/tree/v0.203.0/containers/python-3 | ||
| { | ||
| "name": "Python 3", | ||
| "runArgs": [ | ||
| "--init" | ||
| ], | ||
| "build": { | ||
| "dockerfile": "Dockerfile", | ||
| "context": "..", | ||
| "args": { | ||
| // Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 | ||
| // Append -bullseye or -buster to pin to an OS version. | ||
| // Use -bullseye variants on local on arm64/Apple Silicon. | ||
| "VARIANT": "3.10-bullseye", | ||
| // Options | ||
| "NODE_VERSION": "lts/*" | ||
| } | ||
| }, | ||
| // Set *default* container specific settings.json values on container create. | ||
| "settings": { | ||
| "python.pythonPath": "/usr/local/bin/python", | ||
| "python.languageServer": "Pylance", | ||
| "python.linting.enabled": true, | ||
| "python.linting.flake8Enabled": true, | ||
| "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", | ||
| "python.formatting.blackPath": "/usr/local/py-utils/bin/black", | ||
| "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", | ||
| "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", | ||
| "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", | ||
| "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", | ||
| "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", | ||
| "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", | ||
| "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint", | ||
| "python.analysis.diagnosticMode": "workspace", | ||
| "files.exclude": { | ||
| "**/.ipynb_checkpoints": true, | ||
| "**/.pytest_cache": true, | ||
| "**/*pycache*": true | ||
| }, | ||
| "python.formatting.provider": "black", | ||
| "python.linting.flake8Args": [ | ||
| "--max-line-length=88", | ||
| "--extend-ignore=E203" | ||
| ], | ||
| "editor.formatOnSave": true, | ||
| "editor.codeActionsOnSave": { | ||
| "source.organizeImports": true | ||
| }, | ||
| "python.sortImports.args": [ | ||
| "--multi-line=3", | ||
| "--trailing-comma", | ||
| "--force-grid-wrap=0", | ||
| "--use-parentheses", | ||
| "--line-width=88", | ||
| ] | ||
| }, | ||
| // Add the IDs of extensions you want installed when the container is created. | ||
| "extensions": [ | ||
| "ms-python.python", | ||
| "ms-python.vscode-pylance", | ||
| "ms-azuretools.vscode-docker", | ||
| "donjayamanne.githistory", | ||
| "felipecaputo.git-project-manager", | ||
| "github.copilot-nightly", | ||
| "eamodio.gitlens", | ||
| "davidanson.vscode-markdownlint" | ||
| ], | ||
| // Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
| // "forwardPorts": [], | ||
| // Use 'postCreateCommand' to run commands after the container is created. | ||
| // "postCreateCommand": "pip3 install --user -r requirements.txt", | ||
| // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
| "remoteUser": "vscode", | ||
| "features": { | ||
| "docker-in-docker": "latest", | ||
| "git": "latest", | ||
| "git-lfs": "latest", | ||
| "github-cli": "latest" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "pip" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "daily" | ||
| target-branch: "main" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,32 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
| on: [pull_request, push, workflow_dispatch] | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test / OS ${{ matrix.os }} / Node ${{ matrix.node }} | ||
| name: Test / OS ${{ matrix.os }} / Python ${{ matrix.python-version }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest] | ||
| python-version: [3.6, 3.7, 3.8, 3.9] | ||
| python-version: [3.7, 3.8, 3.9, '3.10'] | ||
| runs-on: ${{ matrix.os }} | ||
| # TODO(fedden): We need to discuss these steps: We could just use a test-supabase instance or we could update the docker image and use that for the tests. | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Clone Repository | ||
| uses: actions/checkout@v2 | ||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v2 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install flake8 pytest requests | ||
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v1 | ||
| - name: Set up Poetry | ||
| uses: abatilo/actions-poetry@v2.1.4 | ||
| with: | ||
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
| poetry-version: 1.1.11 | ||
| - name: Build Docker image | ||
| run: | | ||
| cd infra | ||
| docker-compose down | ||
| docker-compose up -d | ||
| run: make run_infra | ||
| - name: Sleep for 5 seconds | ||
| uses: jakejarvis/wait-action@master | ||
| with: | ||
| time: "5s" | ||
| - name: Test with pytest | ||
| run: | | ||
| pytest -sx | ||
|
|
||
| run: sleep 5 | ||
| - name: Run Tests | ||
| run: make tests | ||
| - name: Upload Coverage | ||
| uses: codecov/codecov-action@v1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.0.1 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: check-added-large-files | ||
| - id: end-of-file-fixer | ||
| - id: mixed-line-ending | ||
| args: ["--fix=lf"] | ||
|
|
||
| - repo: https://github.com/pycqa/isort | ||
| rev: 5.10.1 | ||
| hooks: | ||
| - id: isort | ||
| args: | ||
| [ | ||
| "--profile", | ||
| "black", | ||
| "--multi-line=3", | ||
| "--trailing-comma", | ||
| "--force-grid-wrap=0", | ||
| "--use-parentheses", | ||
| "--line-width=88", | ||
| ] | ||
|
|
||
| - repo: https://github.com/myint/autoflake.git | ||
| rev: v1.4 | ||
| hooks: | ||
| - id: autoflake | ||
| args: | ||
| [ | ||
| "--in-place", | ||
| "--remove-all-unused-imports", | ||
| "--ignore-init-module-imports", | ||
| ] | ||
|
|
||
| - repo: https://github.com/ambv/black | ||
| rev: 21.11b0 | ||
| hooks: | ||
| - id: black | ||
|
|
||
| - repo: https://github.com/asottile/pyupgrade | ||
| rev: v2.29.1 | ||
| hooks: | ||
| - id: pyupgrade | ||
| args: ["--py37-plus", "--keep-runtime-typing"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| install: | ||
| poetry install | ||
|
|
||
| install_poetry: | ||
| curl -sSL https://install.python-poetry.org | python - | ||
| sudo rm -r .venv | ||
| poetry install | ||
|
|
||
| tests: install tests_only tests_pre_commit | ||
|
|
||
| tests_pre_commit: | ||
| poetry run pre-commit run --all-files | ||
|
|
||
| tests_only: | ||
| poetry run pytest --cov=./ --cov-report=xml -vv | ||
|
|
||
| run_infra: | ||
| cd infra &&\ | ||
| docker-compose down &&\ | ||
| docker-compose up -d | ||
|
|
||
| run_tests: run_infra tests | ||
|
|
||
| build_sync: | ||
| poetry run unasync gotrue tests | ||
|
|
||
| build_run_tests: build_sync run_tests | ||
| echo "Done" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.