Skip to content

Commit ff793b4

Browse files
committed
attr errors hashable fix
1 parent 78ede74 commit ff793b4

File tree

8 files changed

+43
-39
lines changed

8 files changed

+43
-39
lines changed

openapi_core/schema/content/exceptions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from openapi_core.schema.exceptions import OpenAPIMappingError
2-
31
import attr
42

3+
from openapi_core.schema.exceptions import OpenAPIMappingError
4+
55

66
class OpenAPIContentError(OpenAPIMappingError):
77
pass
88

99

10-
@attr.s
10+
@attr.s(frozen=True)
1111
class MimeTypeNotFound(OpenAPIContentError):
1212
mimetype = attr.ib()
1313
availableMimetypes = attr.ib()

openapi_core/schema/media_types/exceptions.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
from openapi_core.schema.exceptions import OpenAPIMappingError
2-
31
import attr
42

3+
from openapi_core.schema.exceptions import OpenAPIMappingError
4+
55

66
class OpenAPIMediaTypeError(OpenAPIMappingError):
77
pass
88

9-
@attr.s
9+
10+
@attr.s(frozen=True)
1011
class InvalidMediaTypeValue(OpenAPIMediaTypeError):
1112
original_exception = attr.ib()
1213

1314
def __str__(self):
1415
return "Mimetype invalid: {0}".format(self.original_exception)
1516

16-
@attr.s
17+
18+
@attr.s(frozen=True)
1719
class InvalidContentType(OpenAPIMediaTypeError):
1820
mimetype = attr.ib()
1921

openapi_core/schema/operations/exceptions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from openapi_core.schema.exceptions import OpenAPIMappingError
2-
31
import attr
42

3+
from openapi_core.schema.exceptions import OpenAPIMappingError
4+
55

66
class OpenAPIOperationError(OpenAPIMappingError):
77
pass
88

99

10-
@attr.s
10+
@attr.s(frozen=True)
1111
class InvalidOperation(OpenAPIOperationError):
1212
path_pattern = attr.ib()
1313
http_method = attr.ib()

openapi_core/schema/parameters/exceptions.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
from openapi_core.schema.exceptions import OpenAPIMappingError
2-
31
import attr
42

3+
from openapi_core.schema.exceptions import OpenAPIMappingError
4+
55

66
class OpenAPIParameterError(OpenAPIMappingError):
77
pass
88

99

10-
@attr.s
10+
@attr.s(frozen=True)
1111
class MissingParameter(OpenAPIParameterError):
1212
name = attr.ib()
1313

1414
def __str__(self):
1515
return "Missing parameter (without default value): {0}".format(self.name)
1616

1717

18-
@attr.s
18+
@attr.s(frozen=True)
1919
class MissingRequiredParameter(OpenAPIParameterError):
2020
name = attr.ib()
2121

2222
def __str__(self):
2323
return "Missing required parameter: {0}".format(self.name)
2424

2525

26-
@attr.s
26+
@attr.s(frozen=True)
2727
class EmptyParameterValue(OpenAPIParameterError):
2828
name = attr.ib()
2929

3030
def __str__(self):
3131
return "Value of parameter cannot be empty: {0}".format(self.name)
3232

3333

34-
@attr.s
34+
@attr.s(frozen=True)
3535
class InvalidParameterValue(OpenAPIParameterError):
3636
name = attr.ib()
3737
original_exception = attr.ib()

openapi_core/schema/request_bodies/exceptions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from openapi_core.schema.exceptions import OpenAPIMappingError
2-
31
import attr
42

3+
from openapi_core.schema.exceptions import OpenAPIMappingError
4+
55

66
class OpenAPIRequestBodyError(OpenAPIMappingError):
77
pass
88

99

10-
@attr.s
10+
@attr.s(frozen=True)
1111
class MissingRequestBody(OpenAPIRequestBodyError):
1212
request = attr.ib()
1313

openapi_core/schema/responses/exceptions.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from openapi_core.schema.exceptions import OpenAPIMappingError
2-
31
import attr
42

3+
from openapi_core.schema.exceptions import OpenAPIMappingError
4+
55

66
class OpenAPIResponseError(OpenAPIMappingError):
77
pass
88

99

10-
@attr.s
10+
@attr.s(frozen=True)
1111
class InvalidResponse(OpenAPIResponseError):
1212
http_status = attr.ib()
1313
responses = attr.ib()
@@ -16,7 +16,7 @@ def __str__(self):
1616
return "Unknown response http status: {0}".format(str(self.http_status))
1717

1818

19-
@attr.s
19+
@attr.s(frozen=True)
2020
class MissingResponseContent(OpenAPIResponseError):
2121
response = attr.ib()
2222

openapi_core/schema/schemas/exceptions.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
from openapi_core.schema.exceptions import OpenAPIMappingError
2-
31
import attr
42

3+
from openapi_core.schema.exceptions import OpenAPIMappingError
4+
55

66
class OpenAPISchemaError(OpenAPIMappingError):
77
pass
88

99

10-
@attr.s
10+
@attr.s(frozen=True)
1111
class NoValidSchema(OpenAPISchemaError):
1212
value = attr.ib()
1313

1414
def __str__(self):
1515
return "No valid schema found for value: {0}".format(self.value)
1616

1717

18-
@attr.s
18+
@attr.s(frozen=True)
1919
class UndefinedItemsSchema(OpenAPISchemaError):
2020
type = attr.ib()
2121

2222
def __str__(self):
2323
return "Null value for schema type {0}".format(self.type)
2424

2525

26-
@attr.s
26+
@attr.s(frozen=True)
2727
class InvalidSchemaValue(OpenAPISchemaError):
2828
msg = attr.ib()
2929
value = attr.ib()
@@ -32,58 +32,60 @@ class InvalidSchemaValue(OpenAPISchemaError):
3232
def __str__(self):
3333
return self.msg.format(value=self.value, type=self.type)
3434

35-
@attr.s
35+
36+
@attr.s(frozen=True)
3637
class InvalidCustomFormatSchemaValue(InvalidSchemaValue):
3738
original_exception = attr.ib()
3839

3940
def __str__(self):
4041
return self.msg.format(value=self.value, type=self.type, exception=self.original_exception)
4142

4243

43-
@attr.s
44+
@attr.s(frozen=True)
4445
class UndefinedSchemaProperty(OpenAPISchemaError):
4546
extra_props = attr.ib()
4647

4748
def __str__(self):
4849
return "Extra unexpected properties found in schema: {0}".format(self.extra_props)
4950

50-
@attr.s
51+
52+
@attr.s(frozen=True)
5153
class InvalidSchemaProperty(OpenAPISchemaError):
5254
property_name = attr.ib()
5355
original_exception = attr.ib()
5456

5557
def __str__(self):
5658
return "Invalid schema property {0}: {1}".format(self.property_name, self.original_exception)
5759

58-
@attr.s
60+
61+
@attr.s(frozen=True)
5962
class MissingSchemaProperty(OpenAPISchemaError):
6063
property_name = attr.ib()
6164

6265
def __str__(self):
6366
return "Missing schema property: {0}".format(self.property_name)
6467

6568

66-
@attr.s
69+
@attr.s(frozen=True)
6770
class NoOneOfSchema(OpenAPISchemaError):
6871
type = attr.ib()
6972

7073
def __str__(self):
7174
return "Exactly one valid schema type {0} should be valid, None found.".format(self.type)
7275

7376

74-
@attr.s
77+
@attr.s(frozen=True)
7578
class MultipleOneOfSchema(OpenAPISchemaError):
7679
type = attr.ib()
7780

7881
def __str__(self):
7982
return "Exactly one schema type {0} should be valid, more than one found".format(self.type)
8083

8184

82-
class UnmarshallerError(Exception):
85+
class UnmarshallerError(OpenAPIMappingError):
8386
pass
8487

8588

86-
@attr.s
8789
class UnmarshallerStrictTypeError(UnmarshallerError):
8890
value = attr.ib()
8991
types = attr.ib()

openapi_core/schema/servers/exceptions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from openapi_core.schema.exceptions import OpenAPIMappingError
2-
31
import attr
42

3+
from openapi_core.schema.exceptions import OpenAPIMappingError
4+
55

66
class OpenAPIServerError(OpenAPIMappingError):
77
pass
88

99

10-
@attr.s
10+
@attr.s(frozen=True)
1111
class InvalidServer(OpenAPIServerError):
1212
full_url_pattern = attr.ib()
1313

0 commit comments

Comments
 (0)