Skip to content

Commit

Permalink
fix: enable more ruff checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Nov 11, 2024
1 parent 8b3f1a3 commit 232f7d8
Show file tree
Hide file tree
Showing 184 changed files with 1,342 additions and 896 deletions.
92 changes: 92 additions & 0 deletions .ghjk/lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,55 @@
"crateName": "cargo-udeps",
"locked": true,
"specifiedVersion": true
},
"bciqk32ytmretqjmmjadp4n5737sifnbyxdqkvkq6lvg3w5rxmsku57y": {
"version": "1.1.388",
"buildDepConfigs": {
"cpy_bs_ghrel": {
"version": "3.12.5",
"buildDepConfigs": {
"tar_aa": {
"version": "1.34",
"buildDepConfigs": {},
"portRef": "[email protected]",
"specifiedVersion": false
},
"zstd_aa": {
"version": "v1.4.8,",
"buildDepConfigs": {},
"portRef": "[email protected]",
"specifiedVersion": false
}
},
"portRef": "[email protected]",
"releaseTag": "20240814",
"specifiedVersion": true
}
},
"portRef": "[email protected]",
"packageName": "pyright",
"specifiedVersion": true
},
"bciqon5lanvscx2pvfxplu3yftfwyqb2sc7d7ju7veqbfhraw2okw4xa": {
"version": "1.1.388",
"buildDepConfigs": {
"node_org": {
"version": "v20.8.0",
"buildDepConfigs": {
"tar_aa": {
"version": "1.34",
"buildDepConfigs": {},
"portRef": "[email protected]",
"specifiedVersion": false
}
},
"portRef": "[email protected]",
"specifiedVersion": true
}
},
"portRef": "[email protected]",
"packageName": "pyright",
"specifiedVersion": true
}
}
},
Expand Down Expand Up @@ -770,6 +819,7 @@
"bciqminqcmgw3fbbhibwc7tf6mrupttheic7kpiykadbowqmnzhmzo5a",
"bciqfpjzi6gguk7dafyicfjpzpwtybgyc2dsnxg2zxkcmyinzy7abpla",
"bciqkgncxbauys2qfguplxcz2auxrcyamj4b6htqk2fqvohfm3afd7sa",
"bciqav4kugvq2ceed4xyic2urs5cg2ay5atiwx757u7yhx3cgauf7gqi",
"bciqihcmo6l5uwzih3e3ujc55curep4arfomo6rzkdsfim74unxexiqy",
"bciqezep4ufkgwesldlm5etyfkgdsiickfudx7cosydcz6xtgeorn2hy",
"bciqaixkkacuuligsvtjcfdfgjgl65owtyspiiljb3vmutlgymecsiwq",
Expand Down Expand Up @@ -806,6 +856,7 @@
"bciqminqcmgw3fbbhibwc7tf6mrupttheic7kpiykadbowqmnzhmzo5a",
"bciqfpjzi6gguk7dafyicfjpzpwtybgyc2dsnxg2zxkcmyinzy7abpla",
"bciqkgncxbauys2qfguplxcz2auxrcyamj4b6htqk2fqvohfm3afd7sa",
"bciqav4kugvq2ceed4xyic2urs5cg2ay5atiwx757u7yhx3cgauf7gqi",
"bciqihcmo6l5uwzih3e3ujc55curep4arfomo6rzkdsfim74unxexiqy",
"bciqezep4ufkgwesldlm5etyfkgdsiickfudx7cosydcz6xtgeorn2hy",
"bciqaixkkacuuligsvtjcfdfgjgl65owtyspiiljb3vmutlgymecsiwq",
Expand All @@ -830,6 +881,7 @@
"installs": [
"bciqfpjzi6gguk7dafyicfjpzpwtybgyc2dsnxg2zxkcmyinzy7abpla",
"bciqkgncxbauys2qfguplxcz2auxrcyamj4b6htqk2fqvohfm3afd7sa",
"bciqav4kugvq2ceed4xyic2urs5cg2ay5atiwx757u7yhx3cgauf7gqi",
"bciqihcmo6l5uwzih3e3ujc55curep4arfomo6rzkdsfim74unxexiqy",
"bciqminqcmgw3fbbhibwc7tf6mrupttheic7kpiykadbowqmnzhmzo5a"
],
Expand Down Expand Up @@ -870,6 +922,7 @@
"bciqminqcmgw3fbbhibwc7tf6mrupttheic7kpiykadbowqmnzhmzo5a",
"bciqfpjzi6gguk7dafyicfjpzpwtybgyc2dsnxg2zxkcmyinzy7abpla",
"bciqkgncxbauys2qfguplxcz2auxrcyamj4b6htqk2fqvohfm3afd7sa",
"bciqav4kugvq2ceed4xyic2urs5cg2ay5atiwx757u7yhx3cgauf7gqi",
"bciqihcmo6l5uwzih3e3ujc55curep4arfomo6rzkdsfim74unxexiqy"
],
"allowedBuildDeps": "bciqek3tmrhm4iohl6tvdzlhxwhv7b52makvvgehltxv52d3l7rbki3y"
Expand All @@ -884,6 +937,7 @@
"bciqlt27ioikxnpkqq37hma7ibn5e5wpzfarbvoh77zwdkarwghtvzxa",
"bciqfpjzi6gguk7dafyicfjpzpwtybgyc2dsnxg2zxkcmyinzy7abpla",
"bciqkgncxbauys2qfguplxcz2auxrcyamj4b6htqk2fqvohfm3afd7sa",
"bciqav4kugvq2ceed4xyic2urs5cg2ay5atiwx757u7yhx3cgauf7gqi",
"bciqihcmo6l5uwzih3e3ujc55curep4arfomo6rzkdsfim74unxexiqy"
],
"allowedBuildDeps": "bciqek3tmrhm4iohl6tvdzlhxwhv7b52makvvgehltxv52d3l7rbki3y"
Expand All @@ -898,6 +952,7 @@
"bciqlt27ioikxnpkqq37hma7ibn5e5wpzfarbvoh77zwdkarwghtvzxa",
"bciqfpjzi6gguk7dafyicfjpzpwtybgyc2dsnxg2zxkcmyinzy7abpla",
"bciqkgncxbauys2qfguplxcz2auxrcyamj4b6htqk2fqvohfm3afd7sa",
"bciqav4kugvq2ceed4xyic2urs5cg2ay5atiwx757u7yhx3cgauf7gqi",
"bciqihcmo6l5uwzih3e3ujc55curep4arfomo6rzkdsfim74unxexiqy"
],
"allowedBuildDeps": "bciqek3tmrhm4iohl6tvdzlhxwhv7b52makvvgehltxv52d3l7rbki3y"
Expand Down Expand Up @@ -925,6 +980,7 @@
"bciqjme7csfq43oenkrsakdhaha34hgy6vdwkfffki2ank3kf6mjcguq",
"bciqfpjzi6gguk7dafyicfjpzpwtybgyc2dsnxg2zxkcmyinzy7abpla",
"bciqkgncxbauys2qfguplxcz2auxrcyamj4b6htqk2fqvohfm3afd7sa",
"bciqav4kugvq2ceed4xyic2urs5cg2ay5atiwx757u7yhx3cgauf7gqi",
"bciqihcmo6l5uwzih3e3ujc55curep4arfomo6rzkdsfim74unxexiqy"
],
"allowedBuildDeps": "bciqek3tmrhm4iohl6tvdzlhxwhv7b52makvvgehltxv52d3l7rbki3y"
Expand All @@ -951,6 +1007,7 @@
"bciqminqcmgw3fbbhibwc7tf6mrupttheic7kpiykadbowqmnzhmzo5a",
"bciqfpjzi6gguk7dafyicfjpzpwtybgyc2dsnxg2zxkcmyinzy7abpla",
"bciqkgncxbauys2qfguplxcz2auxrcyamj4b6htqk2fqvohfm3afd7sa",
"bciqav4kugvq2ceed4xyic2urs5cg2ay5atiwx757u7yhx3cgauf7gqi",
"bciqihcmo6l5uwzih3e3ujc55curep4arfomo6rzkdsfim74unxexiqy"
],
"allowedBuildDeps": "bciqek3tmrhm4iohl6tvdzlhxwhv7b52makvvgehltxv52d3l7rbki3y"
Expand Down Expand Up @@ -2798,6 +2855,41 @@
},
"packageName": "ruff"
},
"bciqav4kugvq2ceed4xyic2urs5cg2ay5atiwx757u7yhx3cgauf7gqi": {
"version": "1.1.388",
"port": {
"ty": "denoWorker@v1",
"name": "npmi_npm",
"platforms": [
"x86_64-linux",
"aarch64-linux",
"x86_64-darwin",
"aarch64-darwin",
"x86_64-windows",
"aarch64-windows",
"x86_64-freebsd",
"aarch64-freebsd",
"x86_64-netbsd",
"aarch64-netbsd",
"x86_64-aix",
"aarch64-aix",
"x86_64-solaris",
"aarch64-solaris",
"x86_64-illumos",
"aarch64-illumos",
"x86_64-android",
"aarch64-android"
],
"version": "0.1.0",
"buildDeps": [
{
"name": "node_org"
}
],
"moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/v0.2.1/ports/npmi.ts"
},
"packageName": "pyright"
},
"bciqihcmo6l5uwzih3e3ujc55curep4arfomo6rzkdsfim74unxexiqy": {
"version": "1.8.3",
"port": {
Expand Down
8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ repos:
- tsx
- json
- yaml
files: ^(src/typegate|tools)/
- id: es-lint
name: Eslint website
language: system
Expand All @@ -64,6 +63,13 @@ repos:
# pass_filenames: false
# types:
# - toml
# - id: pyright
# name: Pyright type check
# language: system
# entry: bash -c 'pyright'
# pass_filenames: false
# types:
# - python
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion docs/metatype.dev/docs/guides/securing-requests/cors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: MPL-2.0

# skip:start
from typegraph import typegraph, Policy, t, Graph
from typegraph import Graph, Policy, t, typegraph
from typegraph.graph.params import Cors
from typegraph.runtimes.random import RandomRuntime

Expand Down
5 changes: 4 additions & 1 deletion examples/demo/demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typegraph import typegraph, Policy, t, Graph
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

from typegraph import Graph, Policy, t, typegraph
from typegraph.graph.params import Auth, Rate
from typegraph.providers import PrismaRuntime
from typegraph.runtimes import DenoRuntime, HttpRuntime, PythonRuntime
Expand Down
12 changes: 10 additions & 2 deletions examples/deploy/deploy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

from os import path

from typegraph import Graph, Policy, t, typegraph
Expand Down Expand Up @@ -80,16 +83,21 @@ def deploy_example_python(g: Graph):
# print(res.serialized)
if "errors" in res.response:
print(res.response)
exit
exit()

assert isinstance(res.response, dict)

# migration status.. etc
print("\n".join([msg["text"] for msg in res.response["messages"]]))


migrations = res.response["migrations"] or []
for item in migrations:
# what to do with the migration files?
base_dir = deploy_params.migrations_dir
# Convention, however if migration_dir is absolute then you might want to use that instead
assert base_dir
# Convention, however if migration_dir is absolute then
# you might want to use that instead
# cwd + tg_name + runtime_name
full_path = path.join(base_dir, item["runtime"])
unpack_tarb64(item["migrations"], full_path)
Expand Down
5 changes: 4 additions & 1 deletion examples/templates/python/api/example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typegraph import typegraph, Policy, t, Graph
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

from typegraph import Graph, Policy, t, typegraph
from typegraph.runtimes import PythonRuntime


Expand Down
5 changes: 4 additions & 1 deletion examples/typegraphs/authentication.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

# skip:start
from typegraph import Graph, Policy, t, typegraph
from typegraph.graph.params import Auth, Cors
Expand All @@ -24,7 +27,7 @@ def authentication(g: Graph):
get_context=deno.identity(ctx).apply(
{
"username": g.from_context("username"),
}
},
),
get_full_context=deno.func(
t.struct({}),
Expand Down
7 changes: 5 additions & 2 deletions examples/typegraphs/backend-for-frontend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

# skip:start
from typegraph import typegraph, Policy, t, Graph
from typegraph import Graph, Policy, t, typegraph
from typegraph.graph.params import Cors
from typegraph.runtimes import HttpRuntime

Expand All @@ -22,7 +25,7 @@ def backend_for_frontend(g: Graph):
t.struct({"user": t.string().from_parent("login")}),
t.struct({"name": t.string().optional()}),
),
}
},
)

g.expose(
Expand Down
7 changes: 5 additions & 2 deletions examples/typegraphs/basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

# skip:start
from typegraph import typegraph, Policy, t, Graph
from typegraph import Graph, Policy, t, typegraph
from typegraph.graph.params import Auth, Cors
from typegraph.runtimes.deno import DenoRuntime

Expand All @@ -25,6 +28,6 @@ def basic_authentication(g: Graph):
get_context=deno.identity(ctx).apply(
{
"username": g.from_context("username"),
}
},
),
)
5 changes: 4 additions & 1 deletion examples/typegraphs/cors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

# skip:start
from typegraph import typegraph, Policy, t, Graph
from typegraph import Graph, Policy, t, typegraph
from typegraph.graph.params import Cors
from typegraph.runtimes.random import RandomRuntime

Expand Down
5 changes: 4 additions & 1 deletion examples/typegraphs/database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

# skip:start
from typegraph import typegraph, Policy, t, Graph
from typegraph import Graph, Policy, t, typegraph
from typegraph.graph.params import Cors

# isort: off
Expand Down
5 changes: 4 additions & 1 deletion examples/typegraphs/deno.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

# skip:start
from typegraph import typegraph, Policy, t, Graph
from typegraph import Graph, Policy, t, typegraph
from typegraph.graph.params import Cors
from typegraph.runtimes.deno import DenoRuntime

Expand Down
5 changes: 4 additions & 1 deletion examples/typegraphs/docs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

from typegraph import Policy, t, typegraph
from typegraph.graph.params import Cors
from typegraph.runtimes import HttpRuntime
Expand All @@ -20,7 +23,7 @@ def docs(g):
"email": t.email(),
"listIds": t.list(t.integer()).set([8]),
"header#api-key": t.string().from_secret("SENDINBLUE_KEY"),
}
},
),
t.struct({"id": t.integer().optional()}),
).with_policy(public)
Expand Down
5 changes: 4 additions & 1 deletion examples/typegraphs/example_rest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

# skip:start
from typegraph import Graph, Policy, t, typegraph
from typegraph.graph.params import Cors
Expand Down Expand Up @@ -43,6 +46,6 @@ def example_rest(g: Graph):
}
}
}
"""
""",
)
# highlight-end
20 changes: 11 additions & 9 deletions examples/typegraphs/execute.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from typegraph import typegraph, Policy, t, Graph
from typegraph.runtimes.deno import DenoRuntime
from typegraph.graph.params import Auth
from typegraph.providers.prisma import PrismaRuntime
# Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
# SPDX-License-Identifier: MPL-2.0

from typegraph import Graph, Policy, t, typegraph
from typegraph.gen.exports.runtimes import EffectUpdate
from typegraph.graph.params import Cors
from typegraph.graph.params import Auth, Cors
from typegraph.providers.prisma import PrismaRuntime
from typegraph.runtimes.deno import DenoRuntime


@typegraph(
Expand Down Expand Up @@ -70,8 +72,8 @@ def roadmap(g: Graph):
"authorEmail": g.inherit(),
"votes": g.inherit(),
"bucket": {"connect": g.inherit()},
}
}
},
},
),
create_vote=db.create(vote),
set_vote_importance=db.execute(
Expand All @@ -80,13 +82,13 @@ def roadmap(g: Graph):
{
"vote_id": t.uuid(),
"importance": t.enum(["medium", "important", "critical"]),
}
},
),
EffectUpdate(True),
),
get_context=deno.identity(t.struct({"username": t.string().optional()})).apply(
{
"username": g.from_context("username"),
}
},
),
)
Loading

0 comments on commit 232f7d8

Please sign in to comment.