From 7d43039010643b03a2f8701f5bc35e226e45350c Mon Sep 17 00:00:00 2001 From: Claudia Ng Date: Mon, 2 Oct 2023 20:39:55 -0700 Subject: [PATCH] Addressing PR comments --- .../01_type_hints_for_one_piece_of_data.py | 10 ++++---- ..._type_hints_for_multiple_pieces_of_data.py | 10 ++++---- .../05_type_hints_for_generator.py | 10 ++++---- .../06_type_aliases.py | 5 +--- python-type-hints-multiple-types/README.md | 23 ------------------- .../requirements.txt | 1 - 6 files changed, 16 insertions(+), 43 deletions(-) diff --git a/python-type-hints-multiple-types/01_type_hints_for_one_piece_of_data.py b/python-type-hints-multiple-types/01_type_hints_for_one_piece_of_data.py index 31f1d7688a..282cb2df3e 100644 --- a/python-type-hints-multiple-types/01_type_hints_for_one_piece_of_data.py +++ b/python-type-hints-multiple-types/01_type_hints_for_one_piece_of_data.py @@ -8,8 +8,8 @@ def parse_email(email_address: str) -> str | None: return None -def parse_email(email_address: str) -> Union[str, None]: - if "@" in email_address: - username, domain = email_address.split("@") - return username - return None +# def parse_email(email_address: str) -> Union[str, None]: +# if "@" in email_address: +# username, domain = email_address.split("@") +# return username +# return None diff --git a/python-type-hints-multiple-types/02_type_hints_for_multiple_pieces_of_data.py b/python-type-hints-multiple-types/02_type_hints_for_multiple_pieces_of_data.py index 3c403d1be7..e5b787b7f7 100644 --- a/python-type-hints-multiple-types/02_type_hints_for_multiple_pieces_of_data.py +++ b/python-type-hints-multiple-types/02_type_hints_for_multiple_pieces_of_data.py @@ -8,8 +8,8 @@ def parse_email(email_address: str) -> tuple[str, str] | None: return None -def parse_email(email_address: str) -> Union[Tuple[str, str], None]: - if "@" in email_address: - username, domain = email_address.split("@") - return username, domain - return None +# def parse_email(email_address: str) -> Union[Tuple[str, str], None]: +# if "@" in email_address: +# username, domain = email_address.split("@") +# return username, domain +# return None diff --git a/python-type-hints-multiple-types/05_type_hints_for_generator.py b/python-type-hints-multiple-types/05_type_hints_for_generator.py index 62a14fbd31..97b61634b7 100644 --- a/python-type-hints-multiple-types/05_type_hints_for_generator.py +++ b/python-type-hints-multiple-types/05_type_hints_for_generator.py @@ -29,8 +29,8 @@ def parse_emails(emails: list[str]) -> Iterator[tuple[str, str]]: yield username, domain -def parse_emails(emails: Iterable[str]) -> Iterable[tuple[str, str]]: - for email in emails: - if "@" in email: - username, domain = email.split("@") - yield username, domain +# def parse_emails(emails: Iterable[str]) -> Iterable[tuple[str, str]]: +# for email in emails: +# if "@" in email: +# username, domain = email.split("@") +# yield username, domain diff --git a/python-type-hints-multiple-types/06_type_aliases.py b/python-type-hints-multiple-types/06_type_aliases.py index 40286b5700..880fdd8cbb 100644 --- a/python-type-hints-multiple-types/06_type_aliases.py +++ b/python-type-hints-multiple-types/06_type_aliases.py @@ -1,7 +1,7 @@ from typing import TypeAlias -EmailComponents = tuple[str, str] | None +EmailComponents: TypeAlias = tuple[str, str] | None def parse_email(email_address: str) -> EmailComponents: @@ -9,6 +9,3 @@ def parse_email(email_address: str) -> EmailComponents: username, domain = email_address.split("@") return username, domain return None - - -EmailComponents: TypeAlias = tuple[str, str] | None diff --git a/python-type-hints-multiple-types/README.md b/python-type-hints-multiple-types/README.md index 9ac6e78af5..b420072179 100644 --- a/python-type-hints-multiple-types/README.md +++ b/python-type-hints-multiple-types/README.md @@ -1,4 +1,3 @@ - # How to Use Type Hints for Multiple Return Types in Python This folder contains sample code for the [How to Use Type Hints for Multiple Return Types in Python](https://realpython.com/python-type-hints-multiple-types/) tutorial on Real Python. @@ -16,25 +15,3 @@ $ python3 -m venv venv/ $ source venv/bin/activate (venv) $ python -m pip install -r requirements.txt ``` - -## Running - -### 01_type_hints_for_one_piece_of_data - - -### 02_type_hints_for_multiple_pieces_of_data - - -### 03_type_hints_for_callback - - -### 04_type_hints_for_factory_function - - -### 05_type_hints_for_generator - - -### 06_type_aliases - - -### 07_static_type_checking \ No newline at end of file diff --git a/python-type-hints-multiple-types/requirements.txt b/python-type-hints-multiple-types/requirements.txt index 987a758147..01bdb66600 100644 --- a/python-type-hints-multiple-types/requirements.txt +++ b/python-type-hints-multiple-types/requirements.txt @@ -1,4 +1,3 @@ mypy==1.5.1 mypy-extensions==1.0.0 -tomli==2.0.1 typing_extensions==4.8.0