refactor: Add get_stream_by_narrow_operand_access_unchecked.

This let's us clean up the linter that excludes the use of get_stream
and by adding the access_unchecked in the name we make it clear that
it should be used with caution.

Refactoring idea by Tim Abbott.
This commit is contained in:
Priyank Patel
2019-08-11 16:57:54 +00:00
committed by Tim Abbott
parent 1f8f8867cd
commit 463ecb375f
3 changed files with 22 additions and 16 deletions

View File

@@ -395,10 +395,6 @@ python_rules = RuleList(
# how most instances are written, but better to exclude something than nothing
('zerver/lib/actions.py', 'stream = get_stream(stream_name, realm)'),
('zerver/lib/actions.py', 'get_stream(admin_realm_signup_notifications_stream, admin_realm)'),
# Here we need get_stream to access streams you've since unsubscribed from.
('zerver/views/messages.py', 'stream = get_stream(operand, self.user_profile.realm)'),
# Use stream_id to exclude mutes.
('zerver/views/messages.py', 'stream_id = get_stream(stream_name, user_profile.realm).id'),
]),
'description': 'Please use access_stream_by_*() to fetch Stream objects',
},