diff --git a/.editorconfig b/.editorconfig
index abc4068..90752a7 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -4,8 +4,8 @@
root = true
[*]
-indent_style = space
-indent_size = 4
+indent_style = tab
+indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
@@ -13,3 +13,6 @@ insert_final_newline = true
[*.{py,pyi}]
max_line_length = 80
+
+[*.{yml,yaml}]
+indent_style = space
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 904467b..a0176eb 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,93 +1,100 @@
repos:
- - repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.6.0
- hooks:
- - id: end-of-file-fixer
- - id: trailing-whitespace
- - id: mixed-line-ending
- - id: check-byte-order-marker
- - id: check-executables-have-shebangs
- - id: check-merge-conflict
- - id: check-symlinks
- - id: check-vcs-permalinks
- - id: debug-statements
- - id: check-yaml
- files: .*\.(yaml|yml)$
- - id: check-added-large-files
- - id: check-toml
- - repo: https://github.com/Lucas-C/pre-commit-hooks
- rev: v1.5.5
- hooks:
- - id: insert-license
- name: Add license for all python files
- files: \.py$|\.pyi$
- args:
- [
- --comment-style,
- '"""||"""',
- --license-filepath,
- license-templates/LICENSE.txt,
- --fuzzy-match-generates-todo,
- --use-current-year,
- --no-space,
- ]
- - id: insert-license
- name: Add license for all Markdown files
- files: \.md$
- args:
- [
- --comment-style,
- "",
- --license-filepath,
- license-templates/LICENSE.txt,
- --fuzzy-match-generates-todo,
- --no-space,
- ]
- - repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.4.5
- hooks:
- - id: ruff
- name: Run Ruff Linter & Formater
- args: [--fix, --exit-non-zero-on-fix]
- exclude: |
- (?x)^(
- ^build/|
- ^docker/|
- ^tests/
- )
- - id: ruff-format
- name: Run Ruff Formater
- exclude: |
- (?x)(
- ^build/|
- ^docker/|
- ^tests/
- )
- - repo: https://github.com/pre-commit/mirrors-mypy
- rev: v1.10.0
- hooks:
- - id: mypy
- name: Run Mypy (Static type checker)
- exclude: |
- (?x)(
- ^build/|
- ^docker/|
- ^tests/
- )
- additional_dependencies:
- [strawberry-graphql, pydantic, pydantic-settings, sqlmodel]
- - repo: https://github.com/python-poetry/poetry
- rev: "1.8.0"
- hooks:
- - id: poetry-check
- - id: poetry-lock
- - id: poetry-export
- args: [-o, requirements.txt]
- - repo: https://github.com/commitizen-tools/commitizen
- rev: v3.27.0
- hooks:
- - id: commitizen
- - id: commitizen-branch
- stages:
- - post-commit
- - push
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.6.0
+ hooks:
+ - id: end-of-file-fixer
+ - id: trailing-whitespace
+ - id: mixed-line-ending
+ - id: check-byte-order-marker
+ - id: check-executables-have-shebangs
+ - id: check-merge-conflict
+ - id: check-symlinks
+ - id: check-vcs-permalinks
+ - id: debug-statements
+ - id: check-yaml
+ files: .*\.(yaml|yml)$
+ - id: check-added-large-files
+ args: ["--maxkb=1000"]
+ - id: check-toml
+ - repo: https://github.com/Lucas-C/pre-commit-hooks
+ rev: v1.5.5
+ hooks:
+ - id: insert-license
+ name: Add license for all python files
+ files: \.py$|\.pyi$
+ args:
+ [
+ --comment-style,
+ '"""||"""',
+ --license-filepath,
+ license-templates/LICENSE.txt,
+ --fuzzy-match-generates-todo,
+ --use-current-year,
+ --no-space,
+ ]
+ - id: insert-license
+ name: Add license for all Markdown files
+ files: \.md$
+ args:
+ [
+ --comment-style,
+ "",
+ --license-filepath,
+ license-templates/LICENSE.txt,
+ --fuzzy-match-generates-todo,
+ --no-space,
+ ]
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ rev: v0.5.5
+ hooks:
+ - id: ruff-format
+ name: Run Ruff Formater
+ exclude: |
+ (?x)(
+ ^build/|
+ ^docker/
+ )
+ - id: ruff
+ name: Run Ruff Linter
+ args: [--fix, --exit-non-zero-on-fix]
+ exclude: |
+ (?x)^(
+ ^build/|
+ ^docker/|
+ ^tests/
+ )
+ - repo: https://github.com/pre-commit/mirrors-mypy
+ rev: v1.11.0
+ hooks:
+ - id: mypy
+ name: Run Mypy (Static type checker)
+ exclude: |
+ (?x)(
+ ^build/|
+ ^docker/|
+ ^tests/
+ )
+ additional_dependencies:
+ [
+ "strawberry-graphql[fastapi]",
+ pydantic,
+ pydantic-settings,
+ sqlmodel,
+ ]
+ - repo: https://github.com/python-poetry/poetry
+ rev: "1.8.0"
+ hooks:
+ - id: poetry-check
+ - id: poetry-lock
+ - id: poetry-export
+ args: [-o, requirements.txt]
+ - id: poetry-export
+ args: [-o, requirements_dev.txt, --with=docs]
+ - repo: https://github.com/commitizen-tools/commitizen
+ rev: v3.28.0
+ hooks:
+ - id: commitizen
+ - id: commitizen-branch
+ stages:
+ - post-commit
+ - push
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 60be3a0..1fa368b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see
api.address.graphql_inputs.StateInput
+
+
+api/address/graphql_inputs.py
30 +31 +32 +33 |
|
api.address.graphql_inputs.CityInput
+
+
+api/address/graphql_inputs.py
36 +37 +38 +39 +40 |
|
api.address.graphql_inputs.CoordinatesInput
+
+
+api/address/graphql_inputs.py
43 +44 +45 +46 +47 |
|
api.address.graphql_inputs.AddressFilterInput
+
+
+api/address/graphql_inputs.py
50 +51 +52 +53 +54 +55 +56 +57 |
|
api.address.graphql_inputs.AddressInsertInput
+
+
+api/address/graphql_inputs.py
60 +61 +62 +63 +64 +65 +66 +67 |
|
api.address.graphql_types.StateType
+
+
+api/address/graphql_types.py
32 +33 +34 +35 |
|
api.address.graphql_types.CityType
+
+
+api/address/graphql_types.py
38 +39 +40 +41 +42 |
|
api.address.graphql_types.AddressType
+
+
+api/address/graphql_types.py
45 +46 +47 +48 +49 +50 +51 +52 |
|
api.address.graphql_types.DictResponse
+
+
+
+ Bases: TypedDict
api/address/graphql_types.py
55 +56 +57 |
|
api.app.app = FastAPI()
+
+
+ module-attribute
+
+
+api.app.mkdocs(request)
+
+
+ async
+
+
+Response de mkdocs site, from result of build. +ONLY ENABLED IN DEV MODE.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
request |
+
+ Request
+ |
+
+
+
+ Fastapi Request + |
+ + required + | +
Returns:
+Name | Type | +Description | +
---|---|---|
HTMLResponse |
+ HTMLResponse
+ |
+
+
+
+ Mkdocs static site from documentation/site + |
+
api/app.py
40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 |
|
api.resolvers.get_address(session, filter, page_size, page_number)
+
+
+ async
+
+
+Get all addresses from database or all plugins.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
session |
+
+ AsyncSession
+ |
+
+
+
+ get the session of database from get_session + |
+ + required + | +
filter |
+
+ AddressFilterInput
+ |
+
+
+
+ Strawberry input dataclass, +everything can be None (based on sqlmodel model) + |
+ + required + | +
page_size |
+
+ PositiveInt
+ |
+
+
+
+ How many elements in each page + |
+ + required + | +
page_number |
+
+ PositiveInt
+ |
+
+
+
+ Number of the page + |
+ + required + | +
Returns:
+Name | Type | +Description | +
---|---|---|
DictResponse |
+ DictResponse
+ |
+
+
+
+ 'data' key has all addresses +(db model) based on filter or empty list; +'provider' key has the service provider local or some plugin + |
+
api/resolvers.py
29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 |
|
api.resolvers.insert_address(session, address)
+
+
+ async
+
+
+Insert address and city if not exists on database.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
session |
+
+ AsyncSession
+ |
+
+
+
+ get the session of database from get_session + |
+ + required + | +
address |
+
+ AddressInsertInput
+ |
+
+
+
+ Strict address class, +all needed fields need to be passed + |
+ + required + | +
Returns:
+Name | Type | +Description | +
---|---|---|
Address |
+ Address
+ |
+
+
+
+ Address (db model) + |
+
api/resolvers.py
60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 |
|
api.schema.Query
+
+
+api/schema.py
35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 |
|
all_address(info, filter, page_size=10, page_number=1)
+
+
+ async
+
+
+Query all addresses from database or all plugins.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
info |
+
+ Info
+ |
+
+
+
+ Strawberry default value to get context information +in this case we use 'db' + |
+ + required + | +
filter |
+
+ AddressFilterInput
+ |
+
+
+
+ Strawberry input dataclass, +everything can be None (based on sqlmodel model) + |
+ + required + | +
page_size |
+
+ PositiveInt
+ |
+
+
+
+ How many elements in each page. +Defaults to 10. + |
+
+ 10
+ |
+
page_number |
+
+ PositiveInt
+ |
+
+
+
+ Number of the page. Defaults to 1. + |
+
+ 1
+ |
+
Returns:
+Type | +Description | +
---|---|
+ list[AddressType]
+ |
+
+
+
+ list[AddressType]: All addresses (db model converted to strawberry type) +based on filter or empty list + |
+
api/schema.py
37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 |
|
api.schema.Mutation
+
+
+api/schema.py
79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 |
|
create_address(info, address)
+
+
+ async
+
+
+Insert address and city if not exists on database.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
info |
+
+ Info
+ |
+
+
+
+ Strawberry default value to get context information +in this case we use 'db' + |
+ + required + | +
address |
+
+ AddressInsertInput
+ |
+
+
+
+ Strict address class, +almost all fields need to be passed + |
+ + required + | +
Returns:
+Name | Type | +Description | +
---|---|---|
AddressType |
+ AddressType
+ |
+
+
+
+ Address (db model converted to strawberry dataclass) + |
+
api/schema.py
81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 |
|
api.schema.CustomContext
+
+
+
+ Bases: BaseContext
api/schema.py
103 +104 +105 +106 |
|
__init__(session)
+
+Generate context database session.
+ +api/schema.py
104 +105 +106 |
|
api.schema.get_context(session)
+
+
+ async
+
+
+Create database session to use when needed.
+ + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
session |
+
+ Annotated[AsyncSession, Depends
+ |
+
+
+
+ get db session from get_session + |
+ + required + | +
Returns:
+Name | Type | +Description | +
---|---|---|
CustomContext |
+ CustomContext
+ |
+
+
+
+ class that contains db session + |
+
api/schema.py
109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 |
|
api.schema.schema = Schema(query=Query, mutation=Mutation)
+
+
+ module-attribute
+
+
+Create Graphql Router for fastapi and start graphql ide if env is DEV.
+api.schema.graphql_app = GraphQLRouter[object, object](schema, context_getter=get_context, graphql_ide='graphiql' if settings.DEV else None)
+
+
+ module-attribute
+
+
+