Read an attribute by the first matching name. language_tool_python renamed its Match accessors from camelCase (ruleId, errorLength) to snake_case (rule_id, error_length) between versions; CI pins 2.9.4 (camelCase) while local dev may have a newer release. Try both so the script work
(obj, *names, default=None)
| 505 | |
| 506 | |
| 507 | def _attr(obj, *names, default=None): |
| 508 | """Read an attribute by the first matching name. |
| 509 | |
| 510 | language_tool_python renamed its Match accessors from camelCase |
| 511 | (ruleId, errorLength) to snake_case (rule_id, error_length) between |
| 512 | versions; CI pins 2.9.4 (camelCase) while local dev may have a newer |
| 513 | release. Try both so the script works on either. |
| 514 | """ |
| 515 | for name in names: |
| 516 | try: |
| 517 | val = getattr(obj, name) |
| 518 | except AttributeError: |
| 519 | continue |
| 520 | if val is not None: |
| 521 | return val |
| 522 | return default |
| 523 | |
| 524 | |
| 525 | def matches_to_json(matches, text): |
no outgoing calls
no test coverage detected