python: Excise None from pointlessly nullable booleans.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-04-26 19:23:43 -07:00 committed by Tim Abbott
parent af30538a65
commit fd16f97d6b
7 changed files with 12 additions and 14 deletions

View File

@ -142,11 +142,11 @@ def support(
default=None, str_validator=check_string_in(VALID_BILLING_METHODS)
),
sponsorship_pending: Optional[bool] = REQ(default=None, json_validator=check_bool),
approve_sponsorship: Optional[bool] = REQ(default=None, json_validator=check_bool),
approve_sponsorship: bool = REQ(default=False, json_validator=check_bool),
downgrade_method: Optional[str] = REQ(
default=None, str_validator=check_string_in(VALID_DOWNGRADE_METHODS)
),
scrub_realm: Optional[bool] = REQ(default=None, json_validator=check_bool),
scrub_realm: bool = REQ(default=False, json_validator=check_bool),
query: Optional[str] = REQ("q", default=None),
org_type: Optional[int] = REQ(default=None, converter=to_non_negative_int),
) -> HttpResponse:

View File

@ -336,12 +336,10 @@ MOCKED_STRIPE_FUNCTION_NAMES = [
def mock_stripe(
tested_timestamp_fields: Sequence[str] = [], generate: Optional[bool] = None
tested_timestamp_fields: Sequence[str] = [], generate: bool = settings.GENERATE_STRIPE_FIXTURES
) -> Callable[[Callable[ParamT, ReturnT]], Callable[ParamT, ReturnT]]:
def _mock_stripe(decorated_function: Callable[ParamT, ReturnT]) -> Callable[ParamT, ReturnT]:
generate_fixture = generate
if generate_fixture is None:
generate_fixture = settings.GENERATE_STRIPE_FIXTURES
if generate_fixture: # nocoverage
assert stripe.api_key
for mocked_function_name in MOCKED_STRIPE_FUNCTION_NAMES:

View File

@ -136,8 +136,8 @@ def do_create_realm(
plan_type: Optional[int] = None,
org_type: Optional[int] = None,
date_created: Optional[datetime.datetime] = None,
is_demo_organization: Optional[bool] = False,
enable_spectator_access: Optional[bool] = False,
is_demo_organization: bool = False,
enable_spectator_access: Optional[bool] = None,
) -> Realm:
if string_id == settings.SOCIAL_AUTH_SUBDOMAIN:
raise AssertionError("Creating a realm on SOCIAL_AUTH_SUBDOMAIN is not allowed!")

View File

@ -703,12 +703,12 @@ def flush_stream(
def flush_used_upload_space_cache(
*,
instance: "Attachment",
created: Optional[bool] = None,
created: bool = True,
**kwargs: object,
) -> None:
attachment = instance
if created is None or created:
if created:
cache_delete(get_realm_used_upload_space_cache_key(attachment.owner.realm))

View File

@ -1,5 +1,5 @@
import re
from typing import Any, List, Match, Optional
from typing import Any, List, Match
from markdown import Markdown
from markdown.extensions import Extension
@ -81,7 +81,7 @@ class RelativeLinksHelpExtension(Extension):
)
relative_help_links: Optional[bool] = None
relative_help_links: bool = False
def set_relative_help_links(value: bool) -> None:

View File

@ -1,5 +1,5 @@
import re
from typing import Any, List, Match, Optional
from typing import Any, List, Match
from markdown import Markdown
from markdown.extensions import Extension
@ -114,7 +114,7 @@ class SettingHelpExtension(Extension):
md.preprocessors.register(Setting(), "setting", PREPROCESSOR_PRIORITES["setting"])
relative_settings_links: Optional[bool] = None
relative_settings_links: bool = False
def set_relative_settings_links(value: bool) -> None:

View File

@ -186,7 +186,7 @@ class SubscriptionStreamDict(TypedDict):
email_notifications: Optional[bool]
first_message_id: Optional[int]
history_public_to_subscribers: bool
in_home_view: Optional[bool]
in_home_view: bool
# Bug: invite_only should be bool.
invite_only: Optional[bool]
is_announcement_only: bool