Skip to content

Commit

Permalink
fix: encourage doctype casters over make_ pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Jul 4, 2024
1 parent cb3b67a commit 653052b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions rules/frappe_correctness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ rules:
languages: [python]
severity: ERROR

- id: frappe-prefer-doctype-caster
patterns:
- pattern: |
def $MAKEFUNCTION(...):
...
- metavariable-regex:
metavariable: $MAKEFUNCTION
regex: "^make_(.*)$"
message: |
This is an old pattern. Replace '$MAKEFUNCTION' with 'def _into_*(self, doc)' or 'def _from_*(self, doc)' instance conversion methods.
Check: https://github.com/frappe/frappe/pull/26991 for the implementation and https://github.com/frappe/erpnext/pull/42160/files for an example.
languages: [python]
severity: WARNING
paths:
include:
- "*/**/doctype/*"

- id: frappe-print-function-in-doctypes
pattern: print(...)
message: |
Expand Down
3 changes: 3 additions & 0 deletions rules/some/doctype/frappe_correctness.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ruleid: frappe-avoid-make-functions-prefer-doctype-caster
def make_sales_invoice(...):
...

0 comments on commit 653052b

Please sign in to comment.