permitstack 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. permitstack/__init__.py +17 -0
  2. permitstack/_hooks/__init__.py +4 -0
  3. permitstack/_hooks/sdkhooks.py +74 -0
  4. permitstack/_hooks/types.py +112 -0
  5. permitstack/_version.py +15 -0
  6. permitstack/basesdk.py +396 -0
  7. permitstack/bulk_export.py +241 -0
  8. permitstack/contractors.py +625 -0
  9. permitstack/errors/__init__.py +39 -0
  10. permitstack/errors/httpvalidationerror.py +28 -0
  11. permitstack/errors/no_response_error.py +17 -0
  12. permitstack/errors/permitstackdefaulterror.py +40 -0
  13. permitstack/errors/permitstackerror.py +30 -0
  14. permitstack/errors/responsevalidationerror.py +27 -0
  15. permitstack/health.py +171 -0
  16. permitstack/httpclient.py +125 -0
  17. permitstack/models/__init__.py +158 -0
  18. permitstack/models/contractorprofile.py +108 -0
  19. permitstack/models/contractorsearchresponse.py +24 -0
  20. permitstack/models/contractorsummary.py +57 -0
  21. permitstack/models/delete_webhookop.py +16 -0
  22. permitstack/models/export_permits_csvop.py +98 -0
  23. permitstack/models/get_contractor_permitsop.py +46 -0
  24. permitstack/models/get_contractorop.py +16 -0
  25. permitstack/models/get_permitop.py +16 -0
  26. permitstack/models/get_permits_by_addressop.py +46 -0
  27. permitstack/models/get_property_historyop.py +18 -0
  28. permitstack/models/permitcategory.py +27 -0
  29. permitstack/models/permitdetail.py +164 -0
  30. permitstack/models/permitsearchresponse.py +24 -0
  31. permitstack/models/permitstatus.py +16 -0
  32. permitstack/models/permitsummary.py +121 -0
  33. permitstack/models/propertytype.py +14 -0
  34. permitstack/models/search_contractorsop.py +98 -0
  35. permitstack/models/search_permitsop.py +247 -0
  36. permitstack/models/security.py +42 -0
  37. permitstack/models/validationerror.py +57 -0
  38. permitstack/models/webhookcreate.py +60 -0
  39. permitstack/permits.py +866 -0
  40. permitstack/property_history.py +207 -0
  41. permitstack/py.typed +1 -0
  42. permitstack/sdk.py +218 -0
  43. permitstack/sdkconfiguration.py +49 -0
  44. permitstack/types/__init__.py +21 -0
  45. permitstack/types/basemodel.py +77 -0
  46. permitstack/utils/__init__.py +178 -0
  47. permitstack/utils/annotations.py +79 -0
  48. permitstack/utils/datetimes.py +23 -0
  49. permitstack/utils/dynamic_imports.py +54 -0
  50. permitstack/utils/enums.py +134 -0
  51. permitstack/utils/eventstreaming.py +309 -0
  52. permitstack/utils/forms.py +234 -0
  53. permitstack/utils/headers.py +136 -0
  54. permitstack/utils/logger.py +27 -0
  55. permitstack/utils/metadata.py +119 -0
  56. permitstack/utils/queryparams.py +217 -0
  57. permitstack/utils/requestbodies.py +66 -0
  58. permitstack/utils/retries.py +271 -0
  59. permitstack/utils/security.py +215 -0
  60. permitstack/utils/serializers.py +225 -0
  61. permitstack/utils/unmarshal_json_response.py +38 -0
  62. permitstack/utils/url.py +155 -0
  63. permitstack/utils/values.py +137 -0
  64. permitstack/webhooks.py +593 -0
  65. permitstack-1.0.0.dist-info/METADATA +541 -0
  66. permitstack-1.0.0.dist-info/RECORD +68 -0
  67. permitstack-1.0.0.dist-info/WHEEL +5 -0
  68. permitstack-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,215 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import base64
4
+
5
+ from typing import (
6
+ Any,
7
+ Dict,
8
+ List,
9
+ Optional,
10
+ Tuple,
11
+ )
12
+ from pydantic import BaseModel
13
+ from pydantic.fields import FieldInfo
14
+
15
+ from .metadata import (
16
+ SecurityMetadata,
17
+ find_field_metadata,
18
+ )
19
+ import os
20
+
21
+
22
+ def get_security(
23
+ security: Any, allowed_fields: Optional[List[str]] = None
24
+ ) -> Tuple[Dict[str, str], Dict[str, List[str]]]:
25
+ headers: Dict[str, str] = {}
26
+ query_params: Dict[str, List[str]] = {}
27
+
28
+ if security is None:
29
+ return headers, query_params
30
+
31
+ if not isinstance(security, BaseModel):
32
+ raise TypeError("security must be a pydantic model")
33
+
34
+ sec_fields: Dict[str, FieldInfo] = security.__class__.model_fields
35
+ sec_field_names = (
36
+ list(sec_fields.keys()) if allowed_fields is None else allowed_fields
37
+ )
38
+
39
+ for name in sec_field_names:
40
+ if name not in sec_fields:
41
+ continue
42
+
43
+ sec_field = sec_fields[name]
44
+
45
+ value = getattr(security, name)
46
+ if value is None:
47
+ continue
48
+
49
+ metadata = find_field_metadata(sec_field, SecurityMetadata)
50
+ if metadata is None:
51
+ continue
52
+ if metadata.option:
53
+ _parse_security_option(headers, query_params, value)
54
+ return headers, query_params
55
+ if metadata.scheme:
56
+ # Special case for basic auth or custom auth which could be a flattened model
57
+ if metadata.sub_type in ["basic", "custom"] and not isinstance(
58
+ value, BaseModel
59
+ ):
60
+ _parse_security_scheme(headers, query_params, metadata, name, security)
61
+ else:
62
+ _parse_security_scheme(headers, query_params, metadata, name, value)
63
+
64
+ if not metadata.composite:
65
+ return headers, query_params
66
+
67
+ return headers, query_params
68
+
69
+
70
+ def get_security_from_env(security: Any, security_class: Any) -> Optional[BaseModel]:
71
+ if security is not None:
72
+ return security
73
+
74
+ if not issubclass(security_class, BaseModel):
75
+ raise TypeError("security_class must be a pydantic model class")
76
+
77
+ security_dict: Any = {}
78
+
79
+ if os.getenv("PERMITSTACK_API_KEY"):
80
+ security_dict["api_key"] = os.getenv("PERMITSTACK_API_KEY")
81
+
82
+ return security_class(**security_dict) if security_dict else None
83
+
84
+
85
+ def _parse_security_option(
86
+ headers: Dict[str, str], query_params: Dict[str, List[str]], option: Any
87
+ ):
88
+ if not isinstance(option, BaseModel):
89
+ raise TypeError("security option must be a pydantic model")
90
+
91
+ opt_fields: Dict[str, FieldInfo] = option.__class__.model_fields
92
+
93
+ for name in opt_fields:
94
+ opt_field = opt_fields[name]
95
+
96
+ metadata = find_field_metadata(opt_field, SecurityMetadata)
97
+ if metadata is None or not metadata.scheme:
98
+ continue
99
+
100
+ value = getattr(option, name)
101
+ if (
102
+ metadata.scheme_type == "http"
103
+ and metadata.sub_type == "basic"
104
+ and not isinstance(value, BaseModel)
105
+ ):
106
+ _parse_basic_auth_scheme(headers, option)
107
+ return
108
+
109
+ _parse_security_scheme(headers, query_params, metadata, name, value)
110
+
111
+
112
+ def _parse_security_scheme(
113
+ headers: Dict[str, str],
114
+ query_params: Dict[str, List[str]],
115
+ scheme_metadata: SecurityMetadata,
116
+ field_name: str,
117
+ scheme: Any,
118
+ ):
119
+ scheme_type = scheme_metadata.scheme_type
120
+ sub_type = scheme_metadata.sub_type
121
+
122
+ if isinstance(scheme, BaseModel):
123
+ if scheme_type == "http":
124
+ if sub_type == "basic":
125
+ _parse_basic_auth_scheme(headers, scheme)
126
+ return
127
+ if sub_type == "custom":
128
+ return
129
+
130
+ scheme_fields: Dict[str, FieldInfo] = scheme.__class__.model_fields
131
+ for name in scheme_fields:
132
+ scheme_field = scheme_fields[name]
133
+
134
+ metadata = find_field_metadata(scheme_field, SecurityMetadata)
135
+ if metadata is None or metadata.field_name is None:
136
+ continue
137
+
138
+ value = getattr(scheme, name)
139
+
140
+ _parse_security_scheme_value(
141
+ headers, query_params, scheme_metadata, metadata, name, value
142
+ )
143
+ else:
144
+ _parse_security_scheme_value(
145
+ headers, query_params, scheme_metadata, scheme_metadata, field_name, scheme
146
+ )
147
+
148
+
149
+ def _parse_security_scheme_value(
150
+ headers: Dict[str, str],
151
+ query_params: Dict[str, List[str]],
152
+ scheme_metadata: SecurityMetadata,
153
+ security_metadata: SecurityMetadata,
154
+ field_name: str,
155
+ value: Any,
156
+ ):
157
+ scheme_type = scheme_metadata.scheme_type
158
+ sub_type = scheme_metadata.sub_type
159
+
160
+ header_name = security_metadata.get_field_name(field_name)
161
+
162
+ if scheme_type == "apiKey":
163
+ if sub_type == "header":
164
+ headers[header_name] = value
165
+ elif sub_type == "query":
166
+ query_params[header_name] = [value]
167
+ else:
168
+ raise ValueError("sub type {sub_type} not supported")
169
+ elif scheme_type == "openIdConnect":
170
+ headers[header_name] = _apply_bearer(value)
171
+ elif scheme_type == "oauth2":
172
+ if sub_type != "client_credentials":
173
+ headers[header_name] = _apply_bearer(value)
174
+ elif scheme_type == "http":
175
+ if sub_type == "bearer":
176
+ headers[header_name] = _apply_bearer(value)
177
+ elif sub_type == "basic":
178
+ headers[header_name] = value
179
+ elif sub_type == "custom":
180
+ return
181
+ else:
182
+ raise ValueError("sub type {sub_type} not supported")
183
+ else:
184
+ raise ValueError("scheme type {scheme_type} not supported")
185
+
186
+
187
+ def _apply_bearer(token: str) -> str:
188
+ return token.lower().startswith("bearer ") and token or f"Bearer {token}"
189
+
190
+
191
+ def _parse_basic_auth_scheme(headers: Dict[str, str], scheme: Any):
192
+ username = ""
193
+ password = ""
194
+
195
+ if not isinstance(scheme, BaseModel):
196
+ raise TypeError("basic auth scheme must be a pydantic model")
197
+
198
+ scheme_fields: Dict[str, FieldInfo] = scheme.__class__.model_fields
199
+ for name in scheme_fields:
200
+ scheme_field = scheme_fields[name]
201
+
202
+ metadata = find_field_metadata(scheme_field, SecurityMetadata)
203
+ if metadata is None or metadata.field_name is None:
204
+ continue
205
+
206
+ field_name = metadata.field_name
207
+ value = getattr(scheme, name)
208
+
209
+ if field_name == "username":
210
+ username = value
211
+ if field_name == "password":
212
+ password = value
213
+
214
+ data = f"{username}:{password}".encode()
215
+ headers["Authorization"] = f"Basic {base64.b64encode(data).decode()}"
@@ -0,0 +1,225 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from decimal import Decimal
4
+ import functools
5
+ import json
6
+ import typing
7
+ from typing import Any, Dict, List, Tuple, Union, get_args
8
+ import typing_extensions
9
+ from typing_extensions import get_origin
10
+
11
+ import httpx
12
+ from pydantic import ConfigDict, create_model
13
+ from pydantic_core import from_json
14
+
15
+ from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset
16
+
17
+
18
+ def serialize_decimal(as_str: bool):
19
+ def serialize(d):
20
+ if d is None:
21
+ return None
22
+ if isinstance(d, Unset):
23
+ return d
24
+
25
+ if not isinstance(d, Decimal):
26
+ raise ValueError("Expected Decimal object")
27
+
28
+ return str(d) if as_str else float(d)
29
+
30
+ return serialize
31
+
32
+
33
+ def validate_decimal(d):
34
+ if d is None:
35
+ return None
36
+
37
+ if isinstance(d, (Decimal, Unset)):
38
+ return d
39
+
40
+ if not isinstance(d, (str, int, float)):
41
+ raise ValueError("Expected string, int or float")
42
+
43
+ return Decimal(str(d))
44
+
45
+
46
+ def serialize_float(as_str: bool):
47
+ def serialize(f):
48
+ if f is None:
49
+ return None
50
+ if isinstance(f, Unset):
51
+ return f
52
+
53
+ if not isinstance(f, float):
54
+ raise ValueError("Expected float")
55
+
56
+ return str(f) if as_str else f
57
+
58
+ return serialize
59
+
60
+
61
+ def validate_float(f):
62
+ if f is None:
63
+ return None
64
+
65
+ if isinstance(f, (float, Unset)):
66
+ return f
67
+
68
+ if not isinstance(f, str):
69
+ raise ValueError("Expected string")
70
+
71
+ return float(f)
72
+
73
+
74
+ def serialize_int(as_str: bool):
75
+ def serialize(i):
76
+ if i is None:
77
+ return None
78
+ if isinstance(i, Unset):
79
+ return i
80
+
81
+ if not isinstance(i, int):
82
+ raise ValueError("Expected int")
83
+
84
+ return str(i) if as_str else i
85
+
86
+ return serialize
87
+
88
+
89
+ def validate_int(b):
90
+ if b is None:
91
+ return None
92
+
93
+ if isinstance(b, (int, Unset)):
94
+ return b
95
+
96
+ if not isinstance(b, str):
97
+ raise ValueError("Expected string")
98
+
99
+ return int(b)
100
+
101
+
102
+ def validate_const(v):
103
+ def validate(c):
104
+ if c is None:
105
+ return None
106
+
107
+ if v != c:
108
+ raise ValueError(f"Expected {v}")
109
+
110
+ return c
111
+
112
+ return validate
113
+
114
+
115
+ def unmarshal_json(raw, typ: Any) -> Any:
116
+ return unmarshal(from_json(raw), typ)
117
+
118
+
119
+ def unmarshal(val, typ: Any) -> Any:
120
+ unmarshaller = create_model(
121
+ "Unmarshaller",
122
+ body=(typ, ...),
123
+ __config__=ConfigDict(populate_by_name=True, arbitrary_types_allowed=True),
124
+ )
125
+
126
+ m = unmarshaller(body=val)
127
+
128
+ # pyright: ignore[reportAttributeAccessIssue]
129
+ return m.body # type: ignore
130
+
131
+
132
+ def marshal_json(val, typ):
133
+ if is_nullable(typ) and val is None:
134
+ return "null"
135
+
136
+ marshaller = create_model(
137
+ "Marshaller",
138
+ body=(typ, ...),
139
+ __config__=ConfigDict(populate_by_name=True, arbitrary_types_allowed=True),
140
+ )
141
+
142
+ m = marshaller(body=val)
143
+
144
+ d = m.model_dump(by_alias=True, mode="json", exclude_none=True)
145
+
146
+ if len(d) == 0:
147
+ return ""
148
+
149
+ return json.dumps(d[next(iter(d))], separators=(",", ":"))
150
+
151
+
152
+ def is_nullable(field):
153
+ origin = get_origin(field)
154
+ if origin is Nullable or origin is OptionalNullable:
155
+ return True
156
+
157
+ if not origin is Union or type(None) not in get_args(field):
158
+ return False
159
+
160
+ for arg in get_args(field):
161
+ if get_origin(arg) is Nullable or get_origin(arg) is OptionalNullable:
162
+ return True
163
+
164
+ return False
165
+
166
+
167
+ def is_union(obj: object) -> bool:
168
+ """
169
+ Returns True if the given object is a typing.Union or typing_extensions.Union.
170
+ """
171
+ return any(
172
+ obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union")
173
+ )
174
+
175
+
176
+ def stream_to_text(stream: httpx.Response) -> str:
177
+ return "".join(stream.iter_text())
178
+
179
+
180
+ async def stream_to_text_async(stream: httpx.Response) -> str:
181
+ return "".join([chunk async for chunk in stream.aiter_text()])
182
+
183
+
184
+ def stream_to_bytes(stream: httpx.Response) -> bytes:
185
+ return stream.content
186
+
187
+
188
+ async def stream_to_bytes_async(stream: httpx.Response) -> bytes:
189
+ return await stream.aread()
190
+
191
+
192
+ def get_pydantic_model(data: Any, typ: Any) -> Any:
193
+ if not _contains_pydantic_model(data):
194
+ return unmarshal(data, typ)
195
+
196
+ return data
197
+
198
+
199
+ def _contains_pydantic_model(data: Any) -> bool:
200
+ if isinstance(data, BaseModel):
201
+ return True
202
+ if isinstance(data, List):
203
+ return any(_contains_pydantic_model(item) for item in data)
204
+ if isinstance(data, Dict):
205
+ return any(_contains_pydantic_model(value) for value in data.values())
206
+
207
+ return False
208
+
209
+
210
+ @functools.cache
211
+ def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]:
212
+ """
213
+ Get typing objects by name from typing and typing_extensions.
214
+ Reference: https://typing-extensions.readthedocs.io/en/latest/#runtime-use-of-types
215
+ """
216
+ result = tuple(
217
+ getattr(module, name)
218
+ for module in (typing, typing_extensions)
219
+ if hasattr(module, name)
220
+ )
221
+ if not result:
222
+ raise ValueError(
223
+ f"Neither typing nor typing_extensions has an object called {name!r}"
224
+ )
225
+ return result
@@ -0,0 +1,38 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from typing import Any, Optional, Type, TypeVar, overload
4
+
5
+ import httpx
6
+
7
+ from .serializers import unmarshal_json
8
+ from permitstack import errors
9
+
10
+ T = TypeVar("T")
11
+
12
+
13
+ @overload
14
+ def unmarshal_json_response(
15
+ typ: Type[T], http_res: httpx.Response, body: Optional[str] = None
16
+ ) -> T: ...
17
+
18
+
19
+ @overload
20
+ def unmarshal_json_response(
21
+ typ: Any, http_res: httpx.Response, body: Optional[str] = None
22
+ ) -> Any: ...
23
+
24
+
25
+ def unmarshal_json_response(
26
+ typ: Any, http_res: httpx.Response, body: Optional[str] = None
27
+ ) -> Any:
28
+ if body is None:
29
+ body = http_res.text
30
+ try:
31
+ return unmarshal_json(body, typ)
32
+ except Exception as e:
33
+ raise errors.ResponseValidationError(
34
+ "Response validation failed",
35
+ http_res,
36
+ e,
37
+ body,
38
+ ) from e
@@ -0,0 +1,155 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from decimal import Decimal
4
+ from typing import (
5
+ Any,
6
+ Dict,
7
+ get_type_hints,
8
+ List,
9
+ Optional,
10
+ Union,
11
+ get_args,
12
+ get_origin,
13
+ )
14
+ from pydantic import BaseModel
15
+ from pydantic.fields import FieldInfo
16
+
17
+ from .metadata import (
18
+ PathParamMetadata,
19
+ find_field_metadata,
20
+ )
21
+ from .values import (
22
+ _get_serialized_params,
23
+ _is_set,
24
+ _populate_from_globals,
25
+ _val_to_string,
26
+ )
27
+
28
+
29
+ def generate_url(
30
+ server_url: str,
31
+ path: str,
32
+ path_params: Any,
33
+ gbls: Optional[Any] = None,
34
+ ) -> str:
35
+ path_param_values: Dict[str, str] = {}
36
+
37
+ globals_already_populated = _populate_path_params(
38
+ path_params, gbls, path_param_values, []
39
+ )
40
+ if _is_set(gbls):
41
+ _populate_path_params(gbls, None, path_param_values, globals_already_populated)
42
+
43
+ for key, value in path_param_values.items():
44
+ path = path.replace("{" + key + "}", value, 1)
45
+
46
+ return remove_suffix(server_url, "/") + path
47
+
48
+
49
+ def _populate_path_params(
50
+ path_params: Any,
51
+ gbls: Any,
52
+ path_param_values: Dict[str, str],
53
+ skip_fields: List[str],
54
+ ) -> List[str]:
55
+ globals_already_populated: List[str] = []
56
+
57
+ if not isinstance(path_params, BaseModel):
58
+ return globals_already_populated
59
+
60
+ path_param_fields: Dict[str, FieldInfo] = path_params.__class__.model_fields
61
+ path_param_field_types = get_type_hints(path_params.__class__)
62
+ for name in path_param_fields:
63
+ if name in skip_fields:
64
+ continue
65
+
66
+ field = path_param_fields[name]
67
+
68
+ param_metadata = find_field_metadata(field, PathParamMetadata)
69
+ if param_metadata is None:
70
+ continue
71
+
72
+ param = getattr(path_params, name) if _is_set(path_params) else None
73
+ param, global_found = _populate_from_globals(
74
+ name, param, PathParamMetadata, gbls
75
+ )
76
+ if global_found:
77
+ globals_already_populated.append(name)
78
+
79
+ if not _is_set(param):
80
+ continue
81
+
82
+ f_name = field.alias if field.alias is not None else name
83
+ serialization = param_metadata.serialization
84
+ if serialization is not None:
85
+ serialized_params = _get_serialized_params(
86
+ param_metadata, f_name, param, path_param_field_types[name]
87
+ )
88
+ for key, value in serialized_params.items():
89
+ path_param_values[key] = value
90
+ else:
91
+ pp_vals: List[str] = []
92
+ if param_metadata.style == "simple":
93
+ if isinstance(param, List):
94
+ for pp_val in param:
95
+ if not _is_set(pp_val):
96
+ continue
97
+ pp_vals.append(_val_to_string(pp_val))
98
+ path_param_values[f_name] = ",".join(pp_vals)
99
+ elif isinstance(param, Dict):
100
+ for pp_key in param:
101
+ if not _is_set(param[pp_key]):
102
+ continue
103
+ if param_metadata.explode:
104
+ pp_vals.append(f"{pp_key}={_val_to_string(param[pp_key])}")
105
+ else:
106
+ pp_vals.append(f"{pp_key},{_val_to_string(param[pp_key])}")
107
+ path_param_values[f_name] = ",".join(pp_vals)
108
+ elif not isinstance(param, (str, int, float, complex, bool, Decimal)):
109
+ param_fields: Dict[str, FieldInfo] = param.__class__.model_fields
110
+ for name in param_fields:
111
+ param_field = param_fields[name]
112
+
113
+ param_value_metadata = find_field_metadata(
114
+ param_field, PathParamMetadata
115
+ )
116
+ if param_value_metadata is None:
117
+ continue
118
+
119
+ param_name = (
120
+ param_field.alias if param_field.alias is not None else name
121
+ )
122
+
123
+ param_field_val = getattr(param, name)
124
+ if not _is_set(param_field_val):
125
+ continue
126
+ if param_metadata.explode:
127
+ pp_vals.append(
128
+ f"{param_name}={_val_to_string(param_field_val)}"
129
+ )
130
+ else:
131
+ pp_vals.append(
132
+ f"{param_name},{_val_to_string(param_field_val)}"
133
+ )
134
+ path_param_values[f_name] = ",".join(pp_vals)
135
+ elif _is_set(param):
136
+ path_param_values[f_name] = _val_to_string(param)
137
+
138
+ return globals_already_populated
139
+
140
+
141
+ def is_optional(field):
142
+ return get_origin(field) is Union and type(None) in get_args(field)
143
+
144
+
145
+ def template_url(url_with_params: str, params: Dict[str, str]) -> str:
146
+ for key, value in params.items():
147
+ url_with_params = url_with_params.replace("{" + key + "}", value)
148
+
149
+ return url_with_params
150
+
151
+
152
+ def remove_suffix(input_string, suffix):
153
+ if suffix and input_string.endswith(suffix):
154
+ return input_string[: -len(suffix)]
155
+ return input_string