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']) |                     xrate_limit_reset = int(exc.response.headers['X-RateLimit-Reset']) | ||||||
|                     wait = xrate_limit_reset - now |                     wait = xrate_limit_reset - now | ||||||
|                     if wait > 20: |                     if wait > 20: | ||||||
|                         raise FinishedForNow() |                         raise FinishedForNow() from exc | ||||||
|                     debug(' !', 'Waiting', wait, 'seconds before another try ...') |                     debug(' !', 'Waiting', wait, 'seconds before another try ...') | ||||||
|                     sleep(wait) |                     sleep(wait) | ||||||
|                 continue |                 continue | ||||||
|             return req.json() |             return req.json() | ||||||
|     assert ValueError('Rate limit exceeded') |     raise ValueError('Rate limit exceeded') | ||||||
|  |  | ||||||
|  |  | ||||||
| def new_person(**kwargs: str) -> Person: | def new_person(**kwargs: str) -> Person: | ||||||
|   | |||||||
| @@ -219,8 +219,8 @@ def parse_format_options(s: str, defaults: Optional[dict]) -> dict: | |||||||
|         try: |         try: | ||||||
|             path, value = option.lower().split(':') |             path, value = option.lower().split(':') | ||||||
|             section, key = path.split('.') |             section, key = path.split('.') | ||||||
|         except ValueError: |         except ValueError as exc: | ||||||
|             raise argparse.ArgumentTypeError(f'invalid option {option!r}') |             raise argparse.ArgumentTypeError(f'invalid option {option!r}') from exc | ||||||
|  |  | ||||||
|         if value in value_map: |         if value in value_map: | ||||||
|             parsed_value = value_map[value] |             parsed_value = value_map[value] | ||||||
| @@ -235,9 +235,8 @@ def parse_format_options(s: str, defaults: Optional[dict]) -> dict: | |||||||
|         else: |         else: | ||||||
|             try: |             try: | ||||||
|                 default_value = defaults[section][key] |                 default_value = defaults[section][key] | ||||||
|             except KeyError: |             except KeyError as exc: | ||||||
|                 raise argparse.ArgumentTypeError( |                 raise argparse.ArgumentTypeError(f'invalid key {path!r}') from exc | ||||||
|                     f'invalid key {path!r}') |  | ||||||
|  |  | ||||||
|             default_type, parsed_type = type(default_value), type(parsed_value) |             default_type, parsed_type = type(default_value), type(parsed_value) | ||||||
|             if parsed_type is not default_type: |             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' {value!r} in {option!r}' | ||||||
|                     f' (expected {default_type.__name__}' |                     f' (expected {default_type.__name__}' | ||||||
|                     f' got {parsed_type.__name__})' |                     f' got {parsed_type.__name__})' | ||||||
|                 ) |                 ) from exc | ||||||
|  |  | ||||||
|         options[section][key] = parsed_value |         options[section][key] = parsed_value | ||||||
|  |  | ||||||
| @@ -262,9 +261,8 @@ PARSED_DEFAULT_FORMAT_OPTIONS = parse_format_options( | |||||||
| def response_charset_type(encoding: str) -> str: | def response_charset_type(encoding: str) -> str: | ||||||
|     try: |     try: | ||||||
|         ''.encode(encoding) |         ''.encode(encoding) | ||||||
|     except LookupError: |     except LookupError as exc: | ||||||
|         raise argparse.ArgumentTypeError( |         raise argparse.ArgumentTypeError(f'{encoding!r} is not a supported encoding') from exc | ||||||
|             f'{encoding!r} is not a supported encoding') |  | ||||||
|     return encoding |     return encoding | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -154,7 +154,7 @@ def process_file_upload_arg(arg: KeyValueArg) -> Tuple[str, IO, str]: | |||||||
|     try: |     try: | ||||||
|         f = open(os.path.expanduser(filename), 'rb') |         f = open(os.path.expanduser(filename), 'rb') | ||||||
|     except OSError as e: |     except OSError as e: | ||||||
|         raise ParseError(f'{arg.orig!r}: {e}') |         raise ParseError(f'{arg.orig!r}: {e}') from e | ||||||
|     return ( |     return ( | ||||||
|         os.path.basename(filename), |         os.path.basename(filename), | ||||||
|         f, |         f, | ||||||
| @@ -215,16 +215,16 @@ def load_text_file(item: KeyValueArg) -> str: | |||||||
|         with open(os.path.expanduser(path), 'rb') as f: |         with open(os.path.expanduser(path), 'rb') as f: | ||||||
|             return f.read().decode() |             return f.read().decode() | ||||||
|     except OSError as e: |     except OSError as e: | ||||||
|         raise ParseError(f'{item.orig!r}: {e}') |         raise ParseError(f'{item.orig!r}: {e}') from e | ||||||
|     except UnicodeDecodeError: |     except UnicodeDecodeError as exc: | ||||||
|         raise ParseError( |         raise ParseError( | ||||||
|             f'{item.orig!r}: cannot embed the content of {item.value!r},' |             f'{item.orig!r}: cannot embed the content of {item.value!r},' | ||||||
|             ' not a UTF-8 or ASCII-encoded text file' |             ' not a UTF-8 or ASCII-encoded text file' | ||||||
|         ) |         ) from exc | ||||||
|  |  | ||||||
|  |  | ||||||
| def load_json(arg: KeyValueArg, contents: str) -> JSONType: | def load_json(arg: KeyValueArg, contents: str) -> JSONType: | ||||||
|     try: |     try: | ||||||
|         return load_json_preserve_order_and_dupe_keys(contents) |         return load_json_preserve_order_and_dupe_keys(contents) | ||||||
|     except ValueError as e: |     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: |             try: | ||||||
|                 return json.load(f) |                 return json.load(f) | ||||||
|             except ValueError as e: |             except ValueError as e: | ||||||
|                 raise ConfigFileError( |                 raise ConfigFileError(f'invalid {config_type} file: {e} [{path}]') | ||||||
|                     f'invalid {config_type} file: {e} [{path}]' |  | ||||||
|                 ) |  | ||||||
|     except FileNotFoundError: |     except FileNotFoundError: | ||||||
|         pass |         raise ConfigFileError(f'cannot read {config_type} file: {path} not found') | ||||||
|     except OSError as e: |     except OSError as e: | ||||||
|         raise ConfigFileError(f'cannot read {config_type} file: {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. |     # First, the full data. | ||||||
|     try: |     try: | ||||||
|         return '', load_json_preserve_order_and_dupe_keys(data) |         return '', load_json_preserve_order_and_dupe_keys(data) | ||||||
|     except ValueError: |     except ValueError as exc: | ||||||
|         pass |         raise ValueError('Invalid JSON') from exc | ||||||
|  |  | ||||||
|     # Then, try to find the start of the actual body. |     # Then, try to find the start of the actual body. | ||||||
|     data_prefix, body = parse_prefixed_json(data) |     data_prefix, body = parse_prefixed_json(data) | ||||||
|     try: |     try: | ||||||
|         return data_prefix, load_json_preserve_order_and_dupe_keys(body) |         return data_prefix, load_json_preserve_order_and_dupe_keys(body) | ||||||
|     except ValueError: |     except ValueError as exc: | ||||||
|         raise ValueError('Invalid JSON') |         raise ValueError('Invalid JSON') from exc | ||||||
|  |  | ||||||
|  |  | ||||||
| def parse_prefixed_json(data: str) -> Tuple[str, str]: | def parse_prefixed_json(data: str) -> Tuple[str, str]: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user