* fix: remove redundant isinstance check in encode_dict
The encode_dict function was checking isinstance(d[key], str) twice,
which is redundant. Removed the duplicate check to clean up the code.
This is a simple code quality improvement that removes unnecessary
redundancy in the type checking logic.
* fix: correct decode_dict to check for bytes instead of always-false condition
The decode_dict function had a logic error:
'isinstance(d[key], str) and not isinstance(d[key], str)' is always False.
It should check for bytes instead, since decode() is called on bytes objects.
This fixes the decode_dict function to properly decode bytes to strings.
* fix: remove redundant isinstance check in encode_dict
---------
Co-authored-by: Daniel Miner <daniel@gittensor.miner>
Replaced the old comma-split based email parsing with `email.utils.getaddresses`
to correctly handle RFC 5322 formatted addresses, including display names
containing commas (e.g. `"Last, First" <email@example.com>`).
The previous implementation incorrectly split on commas and treated parts of
display names as standalone emails, causing valid inputs to fail validation and
breaking Communication creation (e.g. `"Gritton, Howard" <hgrit@example.com>`).
The new validator:
- correctly parses display names with commas
- handles multiple addresses and multiline input
- skips undisclosed recipients
- preserves existing EMAIL_MATCH_PATTERN validation
- returns only the email addresses (same as before)
Added additional test cases covering RFC-compliant inputs and empty-addr scenarios.
Fixesfrappe/frappe#27337.
* chore: Drop unused imports
* refactor: split translation utils from init.py
* refactor: move sendmail from init.py
* refactor: move prints to attach_print
* feat: global `frappe.in_test` flag
* feat: helper utility to toggle `frappe.in_test`
* fix: use `toggle_test_mode` util
* fix: use `frappe.in_test`
* chore: add comment explaining global `in_test`
* chore: ignore commit replacing flag usage
* test: temporarily disable `frappe.in_test`
this worked earlier because flag was set in werkzeug.local which was separate for API test client
* test: add comment explaining change
* feat: Add deprecation_dumpster.py file
* docs: add jovial and jocose docstring for frappe/deprecation_dumpster.py
* refactor: fill the dumpster with its own kind
* refactor: move to the deprecation dumpster
* chore: color coding class
* fix: only check import error when import errors
- Scheduled Job sync when type was changed from scheduled to some other
type didn't work.
- It updates on every save with message, bad DX IMO (can't save script
and edit without dismissing)
- This was because of complex walrus which was triggering rest of code
even when nothing changed. Maybe walrus opponents were onto something.
- `Truthy` couples two different operations and hence makes code
complicated. In most cases where these checks are required it's not
performance critical, we can do 1 more function call to avoid this
coupling of change + actual value.
This seems to occur when new files are being created as we're archiving
the files on a site. Doesn't make sense to fail the entire backup
because of that.
Signed-off-by: Akhil Narang <me@akhilnarang.dev>