Skip to content

Commit

Permalink
Addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudia Ng authored and Claudia Ng committed Oct 3, 2023
1 parent 718312b commit 7d43039
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions python-type-hints-multiple-types/05_type_hints_for_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 1 addition & 4 deletions python-type-hints-multiple-types/06_type_aliases.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from typing import TypeAlias


EmailComponents = tuple[str, str] | None
EmailComponents: TypeAlias = tuple[str, str] | None


def parse_email(email_address: str) -> EmailComponents:
if "@" in email_address:
username, domain = email_address.split("@")
return username, domain
return None


EmailComponents: TypeAlias = tuple[str, str] | None
23 changes: 0 additions & 23 deletions python-type-hints-multiple-types/README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
1 change: 0 additions & 1 deletion python-type-hints-multiple-types/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mypy==1.5.1
mypy-extensions==1.0.0
tomli==2.0.1
typing_extensions==4.8.0

0 comments on commit 7d43039

Please sign in to comment.