fix(get_linked_docs): check if user can read doctype before fetching a list by akhilnarang [frappe] PR#31242
From: https://github.com/frappe/frappe/pull/31242
Date: 2025-02-12 17:30:52+05:30
- fix(get_linked_docs): check if user can read doctype before fetching a list
Diagnostics
pre-commit failed for source commit: 80d20ff745e6240fb3a4206cff037bb37b25e4e3
[WARNING] top-level `default_stages` uses deprecated stage names (commit) which will be removed in a future version. run: `pre-commit migrate-config` to automatically fix this.
frappe/desk/form/linked_with.py:143:19: RUF005 Consider `[*self.get_link_sources(), self.root_doctype]` instead of concatenation
|
141 | def get_document_sources(self):
142 | """Return list of doctypes from where we access submittable documents."""
143 | return list(set(self.get_link_sources() + [self.root_doctype]))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005
144 |
145 | def get_link_sources(self):
|
= help: Replace with `[*self.get_link_sources(), self.root_doctype]`
frappe/desk/form/linked_with.py:158:44: RUF013 PEP 484 prohibits implicit `Optional`
|
158 | def get_child_tables_of_doctypes(doctypes: list[str] = None):
| ^^^^^^^^^ RUF013
159 | """Return child tables by doctype."""
160 | filters = [["fieldtype", "=", "Table"]]
|
= help: Convert to `T | None`
frappe/desk/form/linked_with.py:165:26: RUF005 Consider `[*filters, ["parent", "in", tuple(doctypes)]]` instead of concatenation
|
164 | if doctypes:
165 | filters_for_docfield = filters + [["parent", "in", tuple(doctypes)]]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005
166 | filters_for_customfield = filters + [["dt", "in", tuple(doctypes)]]
|
= help: Replace with `[*filters, ["parent", "in", tuple(doctypes)]]`
frappe/desk/form/linked_with.py:166:29: RUF005 Consider `[*filters, ["dt", "in", tuple(doctypes)]]` instead of concatenation
|
164 | if doctypes:
165 | filters_for_docfield = filters + [["parent", "in", tuple(doctypes)]]
166 | filters_for_customfield = filters + [["dt", "in", tuple(doctypes)]]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005
167 |
168 | links = frappe.get_all(
|
= help: Replace with `[*filters, ["dt", "in", tuple(doctypes)]]`
frappe/desk/form/linked_with.py:193:15: RUF013 PEP 484 prohibits implicit `Optional`
|
192 | def get_references_across_doctypes(
193 | to_doctypes: list[str] = None, limit_link_doctypes: list[str] = None
| ^^^^^^^^^ RUF013
194 | ) -> list:
195 | """Find doctype wise foreign key references.
|
= help: Convert to `T | None`
frappe/desk/form/linked_with.py:193:54: RUF013 PEP 484 prohibits implicit `Optional`
|
192 | def get_references_across_doctypes(
193 | to_doctypes: list[str] = None, limit_link_doctypes: list[str] = None
| ^^^^^^^^^ RUF013
194 | ) -> list:
195 | """Find doctype wise foreign key references.
|
= help: Convert to `T | None`
frappe/desk/form/linked_with.py:230:15: RUF013 PEP 484 prohibits implicit `Optional`
|
229 | def get_references_across_doctypes_by_link_field(
230 | to_doctypes: list[str] = None, limit_link_doctypes: list[str] = None
| ^^^^^^^^^ RUF013
231 | ):
232 | """Find doctype wise foreign key references based on link fields.
|
= help: Convert to `T | None`
frappe/desk/form/linked_with.py:230:54: RUF013 PEP 484 prohibits implicit `Optional`
|
229 | def get_references_across_doctypes_by_link_field(
230 | to_doctypes: list[str] = None, limit_link_doctypes: list[str] = None
| ^^^^^^^^^ RUF013
231 | ):
232 | """Find doctype wise foreign key references based on link fields.
|
= help: Convert to `T | None`
frappe/desk/form/linked_with.py:270:15: RUF013 PEP 484 prohibits implicit `Optional`
|
269 | def get_references_across_doctypes_by_dynamic_link_field(
270 | to_doctypes: list[str] = None, limit_link_doctypes: list[str] = None
| ^^^^^^^^^ RUF013
271 | ):
272 | """Find doctype wise foreign key references based on dynamic link fields.
|
= help: Convert to `T | None`
frappe/desk/form/linked_with.py:270:54: RUF013 PEP 484 prohibits implicit `Optional`
|
269 | def get_references_across_doctypes_by_dynamic_link_field(
270 | to_doctypes: list[str] = None, limit_link_doctypes: list[str] = None
| ^^^^^^^^^ RUF013
271 | ):
272 | """Find doctype wise foreign key references based on dynamic link fields.
|
= help: Convert to `T | None`
frappe/desk/form/linked_with.py:328:18: RUF013 PEP 484 prohibits implicit `Optional`
|
326 | link_info: dict,
327 | get_parent_if_child_table_doc: bool = True,
328 | parent_filters: list[list] = None,
| ^^^^^^^^^^ RUF013
329 | child_filters=None,
330 | allowed_parents=None,
|
= help: Convert to `T | None`
Found 11 errors.
No fixes available (11 hidden fixes can be enabled with the `--unsafe-fixes` option).
Checkout instructions
# Checkout locally
git fetch upstream
git switch ft-pr-31242
# Alternatively, re-take the changes
git switch develop
ft take ft-pr-31242
# Make changes then rebase
git rebase -i develop
# Fix or ignore conflicts
git checkout --theirs .
git rebase --continue
# Force-push changes
git push --force-with-lease