|
1 | 1 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license |
2 | 2 |
|
| 3 | +from __future__ import annotations |
| 4 | + |
3 | 5 | import contextlib |
4 | 6 | import re |
5 | 7 | import subprocess |
6 | 8 | from collections import Counter |
7 | 9 | from datetime import datetime |
8 | 10 | from pathlib import Path |
9 | | -from typing import Dict, List, Optional, Tuple |
10 | 11 |
|
11 | 12 | import requests |
12 | 13 | import yaml # YAML is used for its readability and consistency with MkDocs ecosystem |
|
16 | 17 | DEFAULT_AVATAR = requests.head("https://github.com/github.png", allow_redirects=True).url |
17 | 18 |
|
18 | 19 |
|
19 | | -def calculate_time_difference(date_string: str) -> Tuple[str, str]: |
| 20 | +def calculate_time_difference(date_string: str) -> tuple[str, str]: |
20 | 21 | """ |
21 | 22 | Calculate the time difference between a given date and the current date in a human-readable format. |
22 | 23 |
|
@@ -48,7 +49,7 @@ def calculate_time_difference(date_string: str) -> Tuple[str, str]: |
48 | 49 | return difference, pretty_date |
49 | 50 |
|
50 | 51 |
|
51 | | -def get_youtube_video_ids(soup: BeautifulSoup) -> List[str]: |
| 52 | +def get_youtube_video_ids(soup: BeautifulSoup) -> list[str]: |
52 | 53 | """ |
53 | 54 | Extract YouTube video IDs from iframe elements present in the provided BeautifulSoup object. |
54 | 55 |
|
@@ -83,8 +84,8 @@ def get_youtube_video_ids(soup: BeautifulSoup) -> List[str]: |
83 | 84 |
|
84 | 85 |
|
85 | 86 | def get_github_username_from_email( |
86 | | - email: str, cache: Dict, file_path: str = "", verbose: bool = True |
87 | | -) -> Tuple[Optional[str], Optional[str]]: |
| 87 | + email: str, cache: dict, file_path: str = "", verbose: bool = True |
| 88 | +) -> tuple[str | None, str | None]: |
88 | 89 | """ |
89 | 90 | Retrieve the GitHub username and avatar URL associated with the given email address. |
90 | 91 |
|
@@ -137,7 +138,7 @@ def get_github_username_from_email( |
137 | 138 | return None, None |
138 | 139 |
|
139 | 140 |
|
140 | | -def get_github_usernames_from_file(file_path: str, default_user: Optional[str] = None) -> Dict[str, Dict[str, any]]: |
| 141 | +def get_github_usernames_from_file(file_path: str, default_user: str | None = None) -> dict[str, dict[str, any]]: |
141 | 142 | """ |
142 | 143 | Fetch GitHub usernames associated with a file using Git Log and Git Blame commands. |
143 | 144 |
|
|
0 commit comments