From c7102ad3d1ce167665af04e18a7585fef3567fdc Mon Sep 17 00:00:00 2001 From: Mark Mayo Date: Fri, 20 Jan 2023 13:57:22 +1300 Subject: [PATCH 1/2] python 3.5, 3.6 + changes - sorted imports - cleaned up imports - added trailing commas as per 3.5, 3.6+ specs - cleaned up spacing around docstrings - cleaned some quotes and whitespace --- .pymon | Bin 0 -> 24576 bytes docs/contributors/fetch.py | 2 +- docs/contributors/generate.py | 7 +- extras/packaging/linux/build.py | 7 +- .../packaging/linux/scripts/hooks/hook-pip.py | 4 +- extras/profiling/benchmarks.py | 9 +- extras/profiling/run.py | 11 +- extras/scripts/generate_man_pages.py | 30 ++--- httpie/adapters.py | 7 +- httpie/cli/argparser.py | 56 ++++---- httpie/cli/argtypes.py | 6 +- httpie/cli/constants.py | 5 +- httpie/cli/definition.py | 35 ++--- httpie/cli/dicts.py | 2 +- httpie/cli/nested_json/__init__.py | 5 +- httpie/cli/nested_json/errors.py | 4 +- httpie/cli/nested_json/interpret.py | 8 +- httpie/cli/nested_json/parse.py | 19 +-- httpie/cli/nested_json/tokens.py | 2 +- httpie/cli/options.py | 24 ++-- httpie/cli/requestitems.py | 39 +++--- httpie/cli/utils.py | 11 +- httpie/client.py | 38 +++--- httpie/compat.py | 10 +- httpie/config.py | 15 +-- httpie/context.py | 24 ++-- httpie/cookies.py | 2 - httpie/core.py | 37 +++--- httpie/downloads.py | 25 ++-- httpie/encoding.py | 2 +- httpie/internal/daemon_runner.py | 3 +- httpie/internal/daemons.py | 17 +-- httpie/internal/update_warnings.py | 13 +- httpie/legacy/v3_1_0_session_cookie_format.py | 16 +-- httpie/legacy/v3_2_0_session_header_format.py | 12 +- httpie/manager/__main__.py | 7 +- httpie/manager/cli.py | 52 ++++---- httpie/manager/compat.py | 8 +- httpie/manager/core.py | 2 +- httpie/manager/tasks/__init__.py | 6 +- httpie/manager/tasks/check_updates.py | 3 +- httpie/manager/tasks/export_args.py | 5 +- httpie/manager/tasks/plugins.py | 16 +-- httpie/manager/tasks/sessions.py | 14 +- httpie/models.py | 30 ++--- httpie/output/formatters/colors.py | 26 ++-- httpie/output/formatters/json.py | 2 +- httpie/output/formatters/xml.py | 1 + httpie/output/lexers/http.py | 19 +-- httpie/output/lexers/json.py | 5 +- httpie/output/lexers/metadata.py | 12 +- httpie/output/models.py | 10 +- httpie/output/processing.py | 5 +- httpie/output/streams.py | 14 +- httpie/output/ui/man_pages.py | 9 +- httpie/output/ui/palette.py | 9 +- httpie/output/ui/rich_help.py | 6 +- httpie/output/ui/rich_palette.py | 7 +- httpie/output/ui/rich_progress.py | 25 ++-- httpie/output/ui/rich_utils.py | 8 +- httpie/output/writer.py | 43 +++--- httpie/plugins/__init__.py | 5 +- httpie/plugins/base.py | 2 + httpie/plugins/builtin.py | 4 +- httpie/plugins/manager.py | 18 ++- httpie/plugins/registry.py | 7 +- httpie/sessions.py | 36 +++-- httpie/ssl_.py | 20 ++- httpie/status.py | 1 + httpie/uploads.py | 35 ++--- httpie/utils.py | 29 ++--- setup.py | 13 +- tests/conftest.py | 19 +-- tests/fixtures/__init__.py | 4 +- tests/test_auth.py | 15 ++- tests/test_auth_plugins.py | 2 +- tests/test_binary.py | 5 +- tests/test_cli.py | 32 +++-- tests/test_cli_ui.py | 14 +- tests/test_cli_utils.py | 8 +- tests/test_compress.py | 5 +- tests/test_config.py | 15 ++- tests/test_cookie.py | 4 +- tests/test_cookie_on_redirects.py | 39 +++--- tests/test_defaults.py | 5 +- tests/test_downloads.py | 47 +++---- tests/test_encoding.py | 3 +- tests/test_errors.py | 4 +- tests/test_exit_status.py | 3 +- tests/test_httpie.py | 27 ++-- tests/test_httpie_cli.py | 28 ++-- tests/test_json.py | 27 ++-- tests/test_meta.py | 3 +- tests/test_offline.py | 10 +- tests/test_output.py | 87 ++++++------- tests/test_parser_schema.py | 2 +- tests/test_plugins_cli.py | 8 +- tests/test_redirects.py | 6 +- tests/test_regressions.py | 3 +- tests/test_sessions.py | 123 +++++++++--------- tests/test_ssl.py | 12 +- tests/test_stream.py | 28 ++-- tests/test_tokens.py | 4 +- tests/test_update_warnings.py | 18 +-- tests/test_uploads.py | 32 +++-- tests/test_windows.py | 3 +- tests/test_xml.py | 7 +- tests/utils/__init__.py | 31 ++--- tests/utils/http_server.py | 20 +-- tests/utils/matching/__init__.py | 6 +- tests/utils/matching/parsing.py | 6 +- tests/utils/matching/test_matching.py | 15 ++- tests/utils/matching/tokens.py | 6 +- tests/utils/plugins_cli.py | 38 +++--- 114 files changed, 867 insertions(+), 928 deletions(-) create mode 100644 .pymon diff --git a/.pymon b/.pymon new file mode 100644 index 0000000000000000000000000000000000000000..6e0c837494c55a8c7a432713065c48693d16e02d GIT binary patch literal 24576 zcmeI4&2HO95P&5)c3h*b+Fp#_251A@tu2uHrw>IHnT`dUltNNT+#n#9;?ia#kqSjQ zaf=+%pg?au^&$EM>81BPL?5Kb&Qg|SMRpSOR5(NEhvM%1>^HMRiKf@Qd+5g;yfEsq z7z(LRQ|WZ-JAhOwwRHZ(w`5zu*Bj^i;w^n)|Ek@kRPJGMHTzF$art%XlRvY6t^Be4 zdd0n}I~^wiM1Tko0U|&Ih`{?3c=^SRn`^S1{^e23oGw=%sP(qhXzF&osaxs;%bY*5 zSU1#~rGizveW=2GJ8Y}~fU4iK_u-U9of8&ql#83tkNh5s&fqaWgCL9{7lXMy%#V3AIl5=4ciXC7KeDy`@8?>rqn3Kn&_wK>s_!<9NmIU5-b~tz znr2%~t9EE>w`a6zwfcTTS8ctyJJnc{^CPiw>x{j^8;v!iJ{`4uZqPh3EmgA{`d)M1 zo7R!FkGy9Zh0T@C`r^{seL0=-1D8J=Jn7;WPMZzmF!^lHgSX}RV@tn&yl`{v)~)n! z50d~}s%hDpY8j0>`ZV3YF%#5_Eu(OPshXz9i|ObvrdzPR4JIE9{4fCDE~W-{TN^ z5T9^}`5;a_NR+f{*3{*qq+m#d(=8UCj0KQuZwtT5ce~+JKRAZgS$rbK)9Z(*deG+` z994%2KPP&pag>VHkxHFSeGn=qeeHWSqfx`W9?ypSM5dXHo^_$mA{37!|Hs6RaE+l0 zs3tenvuE0e&H5#34BkaCq|q0{@}jT@{WHM<)B7|Wxel%$A+r!?U>qi(g!c6T^g?&o zVT?$Um?C`?h=xHRA|t{(LEAP}W0W0J$qO=m0K)-~ zFn+AV6I%zWp{s{)7kSL1fOjtliK^5#Yj;$bTIuwMs2hbu6aSJeBk3GZ2pho^FC;%n~>0ndnu`y3uHfvl{#`z?|JwGD~aP`c;K> z27@ind=$Usm&Mt26`z^x*QxC9_(B^IAOb{y2oM1xKm>>Y5g-CYfCvzQ51xRZS=4He zK2wx@St`qpTajIbGubVPD` z_xoajhtd|@;la=kc+&enh People: def fetch(url: str, params: Optional[Dict[str, str]] = None) -> UserInfo: headers = { 'Accept': 'application/vnd.github.v3+json', - 'Authentication': f'token {GITHUB_TOKEN}' + 'Authentication': f'token {GITHUB_TOKEN}', } for retry in range(1, 6): debug(f'[{retry}/5]', f'{url = }', f'{params = }') diff --git a/docs/contributors/generate.py b/docs/contributors/generate.py index 27470d5672..2dd10e2d9d 100644 --- a/docs/contributors/generate.py +++ b/docs/contributors/generate.py @@ -3,9 +3,8 @@ """ import sys -from jinja2 import Template - from fetch import HERE, load_awesome_people +from jinja2 import Template TPL_FILE = HERE / 'snippet.jinja2' @@ -13,11 +12,11 @@ 'claudiatd', 'jakubroztocil', 'jkbr', - 'isidentical' + 'isidentical', } BOT_ACCOUNTS = { - 'dependabot-sr' + 'dependabot-sr', } IGNORE_ACCOUNTS = HTTPIE_TEAM | BOT_ACCOUNTS diff --git a/extras/packaging/linux/build.py b/extras/packaging/linux/build.py index 9f02136923..35c813f0e5 100644 --- a/extras/packaging/linux/build.py +++ b/extras/packaging/linux/build.py @@ -7,7 +7,7 @@ HTTPIE_DIR = BUILD_DIR.parent.parent.parent EXTRAS_DIR = HTTPIE_DIR / 'extras' -MAN_PAGES_DIR = EXTRAS_DIR / 'man' +MAN_PAGES_DIR = EXTRAS_DIR / 'man' SCRIPT_DIR = BUILD_DIR / Path('scripts') HOOKS_DIR = SCRIPT_DIR / 'hooks' @@ -33,7 +33,7 @@ def build_binaries() -> Iterator[Tuple[str, Path]]: HOOKS_DIR, *extra_args, target_script, - ] + ], ) for executable_path in DIST_DIR.iterdir(): @@ -61,7 +61,7 @@ def build_packages(http_binary: Path, httpie_binary: Path) -> None: # A list of additional dependencies deps = [ 'python3 >= 3.7', - 'python3-pip' + 'python3-pip', ] processed_deps = [ @@ -104,6 +104,5 @@ def main(): binaries['httpie_cli'].rename(DIST_DIR / 'httpie') - if __name__ == '__main__': main() diff --git a/extras/packaging/linux/scripts/hooks/hook-pip.py b/extras/packaging/linux/scripts/hooks/hook-pip.py index 1dac8fb17f..c8c3fb3540 100644 --- a/extras/packaging/linux/scripts/hooks/hook-pip.py +++ b/extras/packaging/linux/scripts/hooks/hook-pip.py @@ -1,12 +1,12 @@ -from pathlib import Path from PyInstaller.utils.hooks import collect_all + def hook(hook_api): for pkg in [ 'pip', 'setuptools', 'distutils', - 'pkg_resources' + 'pkg_resources', ]: datas, binaries, hiddenimports = collect_all(pkg) hook_api.add_datas(datas) diff --git a/extras/profiling/benchmarks.py b/extras/profiling/benchmarks.py index 9d409debbe..bd7e7f023f 100644 --- a/extras/profiling/benchmarks.py +++ b/extras/profiling/benchmarks.py @@ -60,7 +60,8 @@ def log_message(self, *args, **kwargs): @contextmanager def start_server(): """Create a server to serve local files. It will create the - PREDEFINED_FILES through dd.""" + PREDEFINED_FILES through dd. + """ with TemporaryDirectory() as directory: for file_name, (block_size, count) in PREDEFINED_FILES.items(): subprocess.check_call( @@ -179,8 +180,8 @@ def run(self, context: Context) -> pyperf.Benchmark: [ '--print=HBhb', f'--pretty={pretty}', - 'httpbin.org/stream/1000' - ] + 'httpbin.org/stream/1000', + ], ) DownloadRunner('download', '`http --download :/big_file.txt` (3GB)', '3G') @@ -191,7 +192,7 @@ def main() -> None: # benchmarks 3 times to warm up (e.g especially for download benchmark, this # is important). And then 5 actual runs where we record. sys.argv.extend( - ['--worker', '--loops=1', '--warmup=3', '--values=5', '--processes=2'] + ['--worker', '--loops=1', '--warmup=3', '--values=5', '--processes=2'], ) with Context() as context: diff --git a/extras/profiling/run.py b/extras/profiling/run.py index d03827b0b0..560689edb2 100644 --- a/extras/profiling/run.py +++ b/extras/profiling/run.py @@ -44,8 +44,7 @@ from contextlib import contextmanager from dataclasses import dataclass from pathlib import Path -from typing import (IO, Dict, Generator, Iterable, List, Optional, - Tuple) +from typing import IO, Dict, Generator, Iterable, List, Optional, Tuple BENCHMARK_SCRIPT = Path(__file__).parent / 'benchmarks.py' CURRENT_REPO = Path(__file__).parent.parent.parent @@ -119,7 +118,7 @@ def on_repo(self) -> Generator[Path, None, None]: 'wheel', 'pyperf==2.3.0', *self.dependencies, - ] + ], ) # Create a wheel distribution of HTTPie @@ -148,7 +147,7 @@ def on_repo(self) -> Generator[Path, None, None]: def dump_results( results: List[str], file: IO[str], - min_speed: Optional[str] = None + min_speed: Optional[str] = None, ) -> None: for result in results: lines = result.strip().splitlines() @@ -213,7 +212,7 @@ def iterate(env_name, status): results.append(compare( *config.keys(), directory=result_directory, - min_speed=min_speed + min_speed=min_speed, )) dump_results(results, file=file, min_speed=min_speed) @@ -252,7 +251,7 @@ def main() -> None: parser.add_argument( '--min-speed', help='Minimum of speed in percent to consider that a ' - 'benchmark is significant' + 'benchmark is significant', ) parser.add_argument( '--debug', diff --git a/extras/scripts/generate_man_pages.py b/extras/scripts/generate_man_pages.py index 71e0100f39..fb8f66a7a1 100644 --- a/extras/scripts/generate_man_pages.py +++ b/extras/scripts/generate_man_pages.py @@ -1,7 +1,7 @@ import re from contextlib import contextmanager from pathlib import Path -from typing import Optional, Iterator, Iterable +from typing import Iterable, Iterator, Optional import httpie from httpie.cli.definition import options as core_options @@ -9,18 +9,16 @@ from httpie.manager.cli import options as manager_options from httpie.output.ui.rich_help import OptionsHighlighter, to_usage from httpie.output.ui.rich_utils import render_as_string -from httpie.utils import split_iterable - # Escape certain characters so they are rendered properly on # all terminals. # https://man7.org/linux/man-pages/man7/groff_char.7.html ESCAPE_MAP = { - '"': '\[dq]', - "'": '\[aq]', - '~': '\(ti', - '’': "\(ga", - '\\': '\e', + '"': r'\[dq]', + "'": r'\[aq]', + '~': r'\(ti', + '’': r"\(ga", + '\\': r'\e', } ESCAPE_MAP = {ord(key): value for key, value in ESCAPE_MAP.items()} @@ -29,9 +27,10 @@ PROJECT_ROOT = EXTRAS_DIR.parent OPTION_HIGHLIGHT_RE = re.compile( - OptionsHighlighter.highlights[0] + OptionsHighlighter.highlights[0], ) + class ManPageBuilder: def __init__(self): self.source = [] @@ -45,7 +44,7 @@ def title_line( ) -> None: self.source.append( f'.TH {program_name} 1 "{last_edit_date}" ' - f'"{full_name} {program_version}" "{full_name} Manual"' + f'"{full_name} {program_version}" "{full_name} Manual"', ) def set_name(self, program_name: str) -> None: @@ -65,7 +64,7 @@ def format_desc(self, desc: str) -> str: description = OPTION_HIGHLIGHT_RE.sub( # Boldify the option part, but don't remove the prefix (start of the match). lambda match: match[1] + self.boldify(match['option']), - description + description, ) return description @@ -110,9 +109,9 @@ def _escape_and_dedent(text: str) -> str: def to_man_page(program_name: str, spec: ParserSpec, *, is_top_level_cmd: bool = False) -> str: builder = ManPageBuilder() builder.add_comment( - f"This file is auto-generated from the parser declaration " + "This file is auto-generated from the parser declaration " + (f"in {Path(spec.source_file).relative_to(PROJECT_ROOT)} " if spec.source_file else "") - + f"by {Path(__file__).relative_to(PROJECT_ROOT)}." + + f"by {Path(__file__).relative_to(PROJECT_ROOT)}.", ) builder.title_line( @@ -138,7 +137,7 @@ def to_man_page(program_name: str, spec: ParserSpec, *, is_top_level_cmd: bool = if spec.man_page_hint: builder.write(spec.man_page_hint) - for index, group in enumerate(spec.groups, 1): + for _, group in enumerate(spec.groups, 1): with builder.section(group.name): if group.description: builder.write(group.description) @@ -153,7 +152,7 @@ def to_man_page(program_name: str, spec: ParserSpec, *, is_top_level_cmd: bool = if raw_arg.get('is_positional'): # In case of positional arguments, metavar is always equal # to the list of options (e.g `METHOD`). - metavar = None + metavar = None builder.add_options(raw_arg['options'], metavar=metavar) desc = builder.format_desc(raw_arg.get('description', '')) @@ -178,6 +177,5 @@ def main() -> None: stream.write(to_man_page(program_name, spec, **config)) - if __name__ == '__main__': main() diff --git a/httpie/adapters.py b/httpie/adapters.py index 8e2dd7397f..22adae4096 100644 --- a/httpie/adapters.py +++ b/httpie/adapters.py @@ -1,13 +1,14 @@ -from httpie.cli.dicts import HTTPHeadersDict from requests.adapters import HTTPAdapter +from httpie.cli.dicts import HTTPHeadersDict + class HTTPieHTTPAdapter(HTTPAdapter): def build_response(self, req, resp): """Wrap the original headers with the `HTTPHeadersDict` - to preserve multiple headers that have the same name""" - + to preserve multiple headers that have the same name + """ response = super().build_response(req, resp) response.headers = HTTPHeadersDict(getattr(resp, 'headers', {})) return response diff --git a/httpie/cli/argparser.py b/httpie/cli/argparser.py index 9bf09b3b73..625c7caaa0 100644 --- a/httpie/cli/argparser.py +++ b/httpie/cli/argparser.py @@ -9,24 +9,21 @@ from requests.utils import get_netrc_auth -from .argtypes import ( - AuthCredentials, SSLCredentials, KeyValueArgType, - PARSED_DEFAULT_FORMAT_OPTIONS, - parse_auth, - parse_format_options, -) -from .constants import ( - HTTP_GET, HTTP_POST, BASE_OUTPUT_OPTIONS, OUTPUT_OPTIONS, OUTPUT_OPTIONS_DEFAULT, - OUTPUT_OPTIONS_DEFAULT_OFFLINE, OUTPUT_OPTIONS_DEFAULT_STDOUT_REDIRECTED, - OUT_RESP_BODY, PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, RequestType, - SEPARATOR_CREDENTIALS, - SEPARATOR_GROUP_ALL_ITEMS, SEPARATOR_GROUP_DATA_ITEMS, URL_SCHEME_RE, -) -from .exceptions import ParseError -from .requestitems import RequestItems from ..context import Environment from ..plugins.registry import plugin_manager from ..utils import ExplicitNullAuth, get_content_type +from .argtypes import (PARSED_DEFAULT_FORMAT_OPTIONS, AuthCredentials, + KeyValueArgType, SSLCredentials, parse_auth, + parse_format_options) +from .constants import (BASE_OUTPUT_OPTIONS, HTTP_GET, HTTP_POST, + OUT_RESP_BODY, OUTPUT_OPTIONS, OUTPUT_OPTIONS_DEFAULT, + OUTPUT_OPTIONS_DEFAULT_OFFLINE, + OUTPUT_OPTIONS_DEFAULT_STDOUT_REDIRECTED, PRETTY_MAP, + PRETTY_STDOUT_TTY_ONLY, SEPARATOR_CREDENTIALS, + SEPARATOR_GROUP_ALL_ITEMS, SEPARATOR_GROUP_DATA_ITEMS, + URL_SCHEME_RE, RequestType) +from .exceptions import ParseError +from .requestitems import RequestItems class HTTPieHelpFormatter(RawDescriptionHelpFormatter): @@ -72,7 +69,7 @@ def add_usage(self, usage, actions, groups, prefix=None): usage, displayed_actions, groups, - prefix="usage:\n " + prefix="usage:\n ", ) @@ -91,10 +88,10 @@ def parse_args( self, env: Environment, args=None, - namespace=None + namespace=None, ) -> argparse.Namespace: self.env = env - self.args, no_options = self.parse_known_args(args, namespace) + self.args, _ = self.parse_known_args(args, namespace) if self.args.debug: self.args.traceback = True self.has_stdin_data = ( @@ -117,7 +114,7 @@ def _print_message(self, message, file=None): file = { sys.stdout: env.stdout, sys.stderr: env.stderr, - None: env.stderr + None: env.stderr, }.get(file, file) if not hasattr(file, 'buffer') and isinstance(message, str): @@ -152,7 +149,7 @@ def parse_args( self, env: Environment, args=None, - namespace=None + namespace=None, ) -> argparse.Namespace: self.env = env self.env.args = namespace = namespace or argparse.Namespace() @@ -229,7 +226,6 @@ def _setup_standard_streams(self): Modify `env.stdout` and `env.stdout_isatty` based on args, if needed. """ - self.args.output_file_specified = bool(self.args.output_file) if self.args.download: # FIXME: Come up with a cleaner solution. @@ -295,7 +291,7 @@ def _process_auth(self): key=username, value=password, sep=SEPARATOR_CREDENTIALS, - orig=SEPARATOR_CREDENTIALS.join([username, password]) + orig=SEPARATOR_CREDENTIALS.join([username, password]), ) if self.args.auth is not None or auth_type_set: @@ -313,7 +309,7 @@ def _process_auth(self): key=netrc_credentials[0], value=netrc_credentials[1], sep=SEPARATOR_CREDENTIALS, - orig=SEPARATOR_CREDENTIALS.join(netrc_credentials) + orig=SEPARATOR_CREDENTIALS.join(netrc_credentials), ) if plugin.auth_require and self.args.auth is None: @@ -338,7 +334,7 @@ def _process_auth(self): # Non-tty stdin read by now self.error( 'Unable to prompt for passwords because' - ' --ignore-stdin is set.' + ' --ignore-stdin is set.', ) credentials.prompt_password(url.netloc) @@ -479,7 +475,7 @@ def _parse_items(self): self.error("Can't read request from multiple files") request_file = file - fn, fd, ct = request_file + fn, fd, _ = request_file self.args.files = {} self._body_from_file(fd) @@ -569,11 +565,12 @@ def print_manual(self): with self.env.rich_console.pager(): self.env.rich_console.print( text, - highlight=False + highlight=False, ) def print_usage(self, file): from rich.text import Text + from httpie.output.ui import rich_help whitelist = set() @@ -597,7 +594,8 @@ def print_usage(self, file): def error(self, message): """Prints a usage message incorporating the message to stderr and - exits.""" + exits. + """ self.print_usage(sys.stderr) self.env.rich_error_console.print( dedent( @@ -607,7 +605,7 @@ def error(self, message): [bold]for more information[/bold]: run '{self.prog} --help' or visit https://httpie.io/docs/cli - '''.rstrip() - ) + '''.rstrip(), + ), ) self.exit(2) diff --git a/httpie/cli/argtypes.py b/httpie/cli/argtypes.py index 8f19c3c51e..083271e789 100644 --- a/httpie/cli/argtypes.py +++ b/httpie/cli/argtypes.py @@ -5,8 +5,8 @@ from copy import deepcopy from typing import List, Optional, Union -from .constants import DEFAULT_FORMAT_OPTIONS, SEPARATOR_CREDENTIALS from ..sessions import VALID_SESSION_NAME_PATTERN +from .constants import DEFAULT_FORMAT_OPTIONS, SEPARATOR_CREDENTIALS class KeyValueArg: @@ -184,7 +184,7 @@ def __call__(self, s): key=s, value=None, sep=SEPARATOR_CREDENTIALS, - orig=s + orig=s, ) @@ -245,7 +245,7 @@ def parse_format_options(s: str, defaults: Optional[dict]) -> dict: 'invalid value' f' {value!r} in {option!r}' f' (expected {default_type.__name__}' - f' got {parsed_type.__name__})' + f' got {parsed_type.__name__})', ) options[section][key] = parsed_value diff --git a/httpie/cli/constants.py b/httpie/cli/constants.py index 09ca19e4af..573d5173ad 100644 --- a/httpie/cli/constants.py +++ b/httpie/cli/constants.py @@ -4,7 +4,6 @@ import enum import re - URL_SCHEME_RE = re.compile(r'^[a-z][a-z0-9.+-]*://', re.IGNORECASE) HTTP_POST = 'POST' @@ -32,7 +31,7 @@ SEPARATOR_DATA_RAW_JSON, SEPARATOR_FILE_UPLOAD, SEPARATOR_DATA_EMBED_FILE_CONTENTS, - SEPARATOR_DATA_EMBED_RAW_JSON_FILE + SEPARATOR_DATA_EMBED_RAW_JSON_FILE, }) SEPARATORS_GROUP_MULTIPART = frozenset({ @@ -101,7 +100,7 @@ class PrettyOptions(enum.Enum): 'all': ['format', 'colors'], 'colors': ['colors'], 'format': ['format'], - 'none': [] + 'none': [], } PRETTY_STDOUT_TTY_ONLY = PrettyOptions.STDOUT_TTY_ONLY diff --git a/httpie/cli/definition.py b/httpie/cli/definition.py index 0e5f91edf7..7d4e6dcbcd 100644 --- a/httpie/cli/definition.py +++ b/httpie/cli/definition.py @@ -16,7 +16,8 @@ SORTED_FORMAT_OPTIONS_STRING, UNSORTED_FORMAT_OPTIONS_STRING, RequestType) from httpie.cli.options import ParserSpec, Qualifiers, to_argparse -from httpie.output.formatters.colors import (AUTO_STYLE, DEFAULT_STYLE, BUNDLED_STYLES, +from httpie.output.formatters.colors import (AUTO_STYLE, BUNDLED_STYLES, + DEFAULT_STYLE, get_available_styles) from httpie.plugins.builtin import BuiltinAuthPlugin from httpie.plugins.registry import plugin_manager @@ -32,7 +33,7 @@ Suggestions and bug reports are greatly appreciated: https://github.com/httpie/httpie/issues """, - source_file=__file__ + source_file=__file__, ) @@ -182,14 +183,14 @@ short_help=( 'Similar to --form, but always sends a multipart/form-data ' 'request (i.e., even without files).' - ) + ), ) content_types.add_argument( '--boundary', short_help=( 'Specify a custom boundary string for multipart/form-data requests. ' 'Only has effect only together with --form.' - ) + ), ) content_types.add_argument( '--raw', @@ -311,10 +312,10 @@ def format_style_help(available_styles, *, isolation_mode: bool = False): # The closest approx. of the documented resetting to default via --no-