Skip to content

create_baseline_stubs.py: Modernize a few type annotations #8642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions scripts/create_baseline_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
Run with -h for more help.
"""

from __future__ import annotations

import argparse
import os
import re
import shutil
import subprocess
import sys
from typing import Optional, Tuple

if sys.version_info >= (3, 8):
from importlib.metadata import distribution

PYRIGHT_CONFIG = "pyrightconfig.stricter.json"


def search_pip_freeze_output(project: str, output: str) -> Optional[Tuple[str, str]]:
def search_pip_freeze_output(project: str, output: str) -> tuple[str, str] | None:
# Look for lines such as "typed-ast==1.4.2". '-' matches '_' and
# '_' matches '-' in project name, so that "typed_ast" matches
# "typed-ast", and vice versa.
Expand All @@ -33,7 +34,7 @@ def search_pip_freeze_output(project: str, output: str) -> Optional[Tuple[str, s
return m.group(1), m.group(2)


def get_installed_package_info(project: str) -> Optional[Tuple[str, str]]:
def get_installed_package_info(project: str) -> tuple[str, str] | None:
"""Find package information from pip freeze output.

Match project name somewhat fuzzily (case sensitive; '-' matches '_', and
Expand Down