element-hq / element-hq/synapse
Use `StrCollection` in more places
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#14809](https://github.com/matrix-org/synapse/issues/14809).
---
Using a `Sequence[str]` or `Collection[str]` is bad since a `str` also fits those and you *usually* want this to refer to a `Set[str]`, `List[str]`, `Tuple[str, ...]`, etc.
In #14716 @reivilibre added a `StrCollection` type which we can re-use for this.
This has bit us a few times in the past but I'm failing to find references at the moment.
It would be good to audit `Sequence[str]` and `Collection[str]` and see if any of those should be updated.
Contributor guide
Research direction
Start by searching the Synapse Python codebase for annotations using Sequence[str] and Collection[str], then review each occurrence in the context of its callers. Compare candidates with the StrCollection type added in #14716 and update only cases where accepting a plain str is undesirable. Done means the audit is complete and the appropriate annotations are consistently changed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100