mirror of
https://github.com/langgenius/dify.git
synced 2025-12-20 06:32:45 +00:00
Compare commits
2 Commits
feat/detec
...
feat/sqlal
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
225238b4b2 | ||
|
|
c4ea3e47fd |
2
.github/workflows/autofix.yml
vendored
2
.github/workflows/autofix.yml
vendored
@@ -53,6 +53,8 @@ jobs:
|
||||
# Fix forward references that were incorrectly converted (Python doesn't support "Type" | None syntax)
|
||||
find . -name "*.py" -type f -exec sed -i.bak -E 's/"([^"]+)" \| None/Optional["\1"]/g; s/'"'"'([^'"'"']+)'"'"' \| None/Optional['"'"'\1'"'"']/g' {} \;
|
||||
find . -name "*.py.bak" -type f -delete
|
||||
# Rewrite SQLAlchemy with Type Annotations
|
||||
uvx --from ast-grep-cli sg scan -r dev/ast-grep/rules/remove-nullable-arg.yaml api/models -U
|
||||
|
||||
- name: mdformat
|
||||
run: |
|
||||
|
||||
@@ -1778,7 +1778,7 @@ class MessageAgentThought(Base):
|
||||
answer_price_unit = mapped_column(sa.Numeric(10, 7), nullable=False, server_default=sa.text("0.001"))
|
||||
tokens: Mapped[int | None] = mapped_column(sa.Integer, nullable=True)
|
||||
total_price = mapped_column(sa.Numeric, nullable=True)
|
||||
currency = mapped_column(String, nullable=True)
|
||||
currency: Mapped[str | None] = mapped_column()
|
||||
latency: Mapped[float | None] = mapped_column(sa.Float, nullable=True)
|
||||
created_by_role = mapped_column(String, nullable=False)
|
||||
created_by = mapped_column(StringUUID, nullable=False)
|
||||
|
||||
30
dev/ast-grep/rules/remove-nullable-arg.yaml
Normal file
30
dev/ast-grep/rules/remove-nullable-arg.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
id: remove-nullable-arg
|
||||
language: python
|
||||
rule:
|
||||
pattern: $X = mapped_column($$$ARGS)
|
||||
any:
|
||||
- pattern: $X = mapped_column($$$BEFORE, sa.String, $$$MID, nullable=True, $$$AFTER)
|
||||
- pattern: $X = mapped_column($$$BEFORE, sa.String, $$$MID, nullable=True)
|
||||
rewriters:
|
||||
- id: filter-string-nullable
|
||||
rule:
|
||||
pattern: $ARG
|
||||
inside:
|
||||
kind: argument_list
|
||||
all:
|
||||
- not:
|
||||
pattern: String
|
||||
- not:
|
||||
pattern:
|
||||
context: a(nullable=True)
|
||||
selector: keyword_argument
|
||||
fix: $ARG
|
||||
|
||||
transform:
|
||||
NEWARGS:
|
||||
rewrite:
|
||||
rewriters: [filter-string-nullable]
|
||||
source: $$$ARGS
|
||||
joinBy: ', '
|
||||
fix: |-
|
||||
$X: Mapped[str | None] = mapped_column($NEWARGS)
|
||||
Reference in New Issue
Block a user