Skip to content

Commit b1b9925

Browse files
committed
chore: use mypy for lint check
1 parent 0cfadb5 commit b1b9925

File tree

4 files changed

+21
-46
lines changed

4 files changed

+21
-46
lines changed

.github/workflows/validate-python-types.yml

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
- name: Install Python dependencies
3535
run: |
36-
pip install pydantic typing-extensions
36+
pip install pydantic mypy
3737
3838
- name: Start test database
3939
working-directory: test/db
@@ -57,46 +57,13 @@ jobs:
5757
echo "Generated Python types (first 30 lines):"
5858
head -30 generated_types.py
5959
60-
- name: Validate Python types syntax
60+
- name: Validate Python types runtime
6161
run: |
62-
python -m py_compile generated_types.py
63-
echo "✓ Python syntax is valid"
62+
python -c "import generated_types; print('✓ Generated Python types are valid and can be imported')"
6463
65-
- name: Validate Python types imports
64+
- name: Validate Python types with mypy
6665
run: |
67-
python << 'EOF'
68-
import sys
69-
import importlib.util
70-
71-
try:
72-
# Load the module from file
73-
spec = importlib.util.spec_from_file_location("generated_types", "generated_types.py")
74-
if spec is None or spec.loader is None:
75-
print("✗ Failed to create module spec")
76-
sys.exit(1)
77-
78-
module = importlib.util.module_from_spec(spec)
79-
spec.loader.exec_module(module)
80-
81-
print("✓ All imports are valid")
82-
print("✓ Generated types can be imported successfully")
83-
print(f"✓ Module loaded: {module.__name__}")
84-
except ImportError as e:
85-
print(f"✗ Import error: {e}")
86-
import traceback
87-
traceback.print_exc()
88-
sys.exit(1)
89-
except SyntaxError as e:
90-
print(f"✗ Syntax error: {e}")
91-
import traceback
92-
traceback.print_exc()
93-
sys.exit(1)
94-
except Exception as e:
95-
print(f"✗ Unexpected error: {e}")
96-
import traceback
97-
traceback.print_exc()
98-
sys.exit(1)
99-
EOF
66+
mypy generated_types.py --strict
10067
10168
- name: Cleanup
10269
if: always()

test/lib/tables.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ test('list', async () => {
3737
id: expect.any(Number),
3838
live_rows_estimate: expect.any(Number),
3939
size: expect.any(String),
40-
}, `
40+
},
41+
`
4142
{
4243
"bytes": Any<Number>,
4344
"columns": [
@@ -173,7 +174,8 @@ test('list', async () => {
173174
"schema": "public",
174175
"size": Any<String>,
175176
}
176-
`)
177+
`
178+
)
177179
})
178180

179181
test('list without columns', async () => {

test/lib/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ test('list types with include Table Types', async () => {
6464
})
6565

6666
expect(res.data?.find(({ name }) => name === 'todos')).toMatchInlineSnapshot(
67-
{ id: expect.any(Number) }, `
67+
{ id: expect.any(Number) },
68+
`
6869
{
6970
"attributes": [],
7071
"comment": null,
@@ -75,7 +76,8 @@ test('list types with include Table Types', async () => {
7576
"schema": "public",
7677
"type_relation_id": 16403,
7778
}
78-
`)
79+
`
80+
)
7981
})
8082

8183
test('list types without Table Types', async () => {

test/lib/views.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { pgMeta } from './utils'
44
test('list', async () => {
55
const res = await pgMeta.views.list()
66
expect(res.data?.find(({ name }) => name === 'todos_view')).toMatchInlineSnapshot(
7-
{ id: expect.any(Number) }, `
7+
{ id: expect.any(Number) },
8+
`
89
{
910
"columns": [
1011
{
@@ -74,7 +75,8 @@ test('list', async () => {
7475
"name": "todos_view",
7576
"schema": "public",
7677
}
77-
`)
78+
`
79+
)
7880
})
7981

8082
test('list without columns', async () => {
@@ -98,7 +100,8 @@ test('list without columns', async () => {
98100
test('retrieve', async () => {
99101
const res = await pgMeta.views.retrieve({ schema: 'public', name: 'todos_view' })
100102
expect(res).toMatchInlineSnapshot(
101-
{ data: { id: expect.any(Number) } }, `
103+
{ data: { id: expect.any(Number) } },
104+
`
102105
{
103106
"data": {
104107
"columns": [
@@ -171,5 +174,6 @@ test('retrieve', async () => {
171174
},
172175
"error": null,
173176
}
174-
`)
177+
`
178+
)
175179
})

0 commit comments

Comments
 (0)