You've already forked httpie-cli
							
							
				mirror of
				https://github.com/httpie/cli.git
				synced 2025-10-30 23:47:52 +02:00 
			
		
		
		
	Fix pylint warning raise-missing-from
				
					
				
			This commit is contained in:
		| @@ -207,12 +207,12 @@ def fetch(url: str, params: Optional[Dict[str, str]] = None) -> UserInfo: | ||||
|                     xrate_limit_reset = int(exc.response.headers['X-RateLimit-Reset']) | ||||
|                     wait = xrate_limit_reset - now | ||||
|                     if wait > 20: | ||||
|                         raise FinishedForNow() | ||||
|                         raise FinishedForNow() from exc | ||||
|                     debug(' !', 'Waiting', wait, 'seconds before another try ...') | ||||
|                     sleep(wait) | ||||
|                 continue | ||||
|             return req.json() | ||||
|     assert ValueError('Rate limit exceeded') | ||||
|     raise ValueError('Rate limit exceeded') | ||||
|  | ||||
|  | ||||
| def new_person(**kwargs: str) -> Person: | ||||
|   | ||||
| @@ -219,8 +219,8 @@ def parse_format_options(s: str, defaults: Optional[dict]) -> dict: | ||||
|         try: | ||||
|             path, value = option.lower().split(':') | ||||
|             section, key = path.split('.') | ||||
|         except ValueError: | ||||
|             raise argparse.ArgumentTypeError(f'invalid option {option!r}') | ||||
|         except ValueError as exc: | ||||
|             raise argparse.ArgumentTypeError(f'invalid option {option!r}') from exc | ||||
|  | ||||
|         if value in value_map: | ||||
|             parsed_value = value_map[value] | ||||
| @@ -235,9 +235,8 @@ def parse_format_options(s: str, defaults: Optional[dict]) -> dict: | ||||
|         else: | ||||
|             try: | ||||
|                 default_value = defaults[section][key] | ||||
|             except KeyError: | ||||
|                 raise argparse.ArgumentTypeError( | ||||
|                     f'invalid key {path!r}') | ||||
|             except KeyError as exc: | ||||
|                 raise argparse.ArgumentTypeError(f'invalid key {path!r}') from exc | ||||
|  | ||||
|             default_type, parsed_type = type(default_value), type(parsed_value) | ||||
|             if parsed_type is not default_type: | ||||
| @@ -246,7 +245,7 @@ def parse_format_options(s: str, defaults: Optional[dict]) -> dict: | ||||
|                     f' {value!r} in {option!r}' | ||||
|                     f' (expected {default_type.__name__}' | ||||
|                     f' got {parsed_type.__name__})' | ||||
|                 ) | ||||
|                 ) from exc | ||||
|  | ||||
|         options[section][key] = parsed_value | ||||
|  | ||||
| @@ -262,9 +261,8 @@ PARSED_DEFAULT_FORMAT_OPTIONS = parse_format_options( | ||||
| def response_charset_type(encoding: str) -> str: | ||||
|     try: | ||||
|         ''.encode(encoding) | ||||
|     except LookupError: | ||||
|         raise argparse.ArgumentTypeError( | ||||
|             f'{encoding!r} is not a supported encoding') | ||||
|     except LookupError as exc: | ||||
|         raise argparse.ArgumentTypeError(f'{encoding!r} is not a supported encoding') from exc | ||||
|     return encoding | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -154,7 +154,7 @@ def process_file_upload_arg(arg: KeyValueArg) -> Tuple[str, IO, str]: | ||||
|     try: | ||||
|         f = open(os.path.expanduser(filename), 'rb') | ||||
|     except OSError as e: | ||||
|         raise ParseError(f'{arg.orig!r}: {e}') | ||||
|         raise ParseError(f'{arg.orig!r}: {e}') from e | ||||
|     return ( | ||||
|         os.path.basename(filename), | ||||
|         f, | ||||
| @@ -215,16 +215,16 @@ def load_text_file(item: KeyValueArg) -> str: | ||||
|         with open(os.path.expanduser(path), 'rb') as f: | ||||
|             return f.read().decode() | ||||
|     except OSError as e: | ||||
|         raise ParseError(f'{item.orig!r}: {e}') | ||||
|     except UnicodeDecodeError: | ||||
|         raise ParseError(f'{item.orig!r}: {e}') from e | ||||
|     except UnicodeDecodeError as exc: | ||||
|         raise ParseError( | ||||
|             f'{item.orig!r}: cannot embed the content of {item.value!r},' | ||||
|             ' not a UTF-8 or ASCII-encoded text file' | ||||
|         ) | ||||
|         ) from exc | ||||
|  | ||||
|  | ||||
| def load_json(arg: KeyValueArg, contents: str) -> JSONType: | ||||
|     try: | ||||
|         return load_json_preserve_order_and_dupe_keys(contents) | ||||
|     except ValueError as e: | ||||
|         raise ParseError(f'{arg.orig!r}: {e}') | ||||
|         raise ParseError(f'{arg.orig!r}: {e}') from e | ||||
|   | ||||
| @@ -68,11 +68,9 @@ def read_raw_config(config_type: str, path: Path) -> Dict[str, Any]: | ||||
|             try: | ||||
|                 return json.load(f) | ||||
|             except ValueError as e: | ||||
|                 raise ConfigFileError( | ||||
|                     f'invalid {config_type} file: {e} [{path}]' | ||||
|                 ) | ||||
|                 raise ConfigFileError(f'invalid {config_type} file: {e} [{path}]') | ||||
|     except FileNotFoundError: | ||||
|         pass | ||||
|         raise ConfigFileError(f'cannot read {config_type} file: {path} not found') | ||||
|     except OSError as e: | ||||
|         raise ConfigFileError(f'cannot read {config_type} file: {e}') | ||||
|  | ||||
|   | ||||
| @@ -13,15 +13,15 @@ def load_prefixed_json(data: str) -> Tuple[str, json.JSONDecoder]: | ||||
|     # First, the full data. | ||||
|     try: | ||||
|         return '', load_json_preserve_order_and_dupe_keys(data) | ||||
|     except ValueError: | ||||
|         pass | ||||
|     except ValueError as exc: | ||||
|         raise ValueError('Invalid JSON') from exc | ||||
|  | ||||
|     # Then, try to find the start of the actual body. | ||||
|     data_prefix, body = parse_prefixed_json(data) | ||||
|     try: | ||||
|         return data_prefix, load_json_preserve_order_and_dupe_keys(body) | ||||
|     except ValueError: | ||||
|         raise ValueError('Invalid JSON') | ||||
|     except ValueError as exc: | ||||
|         raise ValueError('Invalid JSON') from exc | ||||
|  | ||||
|  | ||||
| def parse_prefixed_json(data: str) -> Tuple[str, str]: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user