| 101 | |
| 102 | |
| 103 | class FieldInfo(PydanticFieldInfo): # ty: ignore[subclass-of-final-class] |
| 104 | # mypy - ignore that PydanticFieldInfo is @final |
| 105 | def __init__(self, default: Any = Undefined, **kwargs: Any) -> None: |
| 106 | primary_key = kwargs.pop("primary_key", False) |
| 107 | nullable = kwargs.pop("nullable", Undefined) |
| 108 | foreign_key = kwargs.pop("foreign_key", Undefined) |
| 109 | ondelete = kwargs.pop("ondelete", Undefined) |
| 110 | unique = kwargs.pop("unique", False) |
| 111 | index = kwargs.pop("index", Undefined) |
| 112 | sa_type = kwargs.pop("sa_type", Undefined) |
| 113 | sa_column = kwargs.pop("sa_column", Undefined) |
| 114 | sa_column_args = kwargs.pop("sa_column_args", Undefined) |
| 115 | sa_column_kwargs = kwargs.pop("sa_column_kwargs", Undefined) |
| 116 | if sa_column is not Undefined: |
| 117 | if sa_column_args is not Undefined: |
| 118 | raise RuntimeError( |
| 119 | "Passing sa_column_args is not supported when " |
| 120 | "also passing a sa_column" |
| 121 | ) |
| 122 | if sa_column_kwargs is not Undefined: |
| 123 | raise RuntimeError( |
| 124 | "Passing sa_column_kwargs is not supported when " |
| 125 | "also passing a sa_column" |
| 126 | ) |
| 127 | if primary_key is not Undefined: |
| 128 | raise RuntimeError( |
| 129 | "Passing primary_key is not supported when also passing a sa_column" |
| 130 | ) |
| 131 | if nullable is not Undefined: |
| 132 | raise RuntimeError( |
| 133 | "Passing nullable is not supported when also passing a sa_column" |
| 134 | ) |
| 135 | if foreign_key is not Undefined: |
| 136 | raise RuntimeError( |
| 137 | "Passing foreign_key is not supported when also passing a sa_column" |
| 138 | ) |
| 139 | if ondelete is not Undefined: |
| 140 | raise RuntimeError( |
| 141 | "Passing ondelete is not supported when also passing a sa_column" |
| 142 | ) |
| 143 | if unique is not Undefined: |
| 144 | raise RuntimeError( |
| 145 | "Passing unique is not supported when also passing a sa_column" |
| 146 | ) |
| 147 | if index is not Undefined: |
| 148 | raise RuntimeError( |
| 149 | "Passing index is not supported when also passing a sa_column" |
| 150 | ) |
| 151 | if sa_type is not Undefined: |
| 152 | raise RuntimeError( |
| 153 | "Passing sa_type is not supported when also passing a sa_column" |
| 154 | ) |
| 155 | if ondelete is not Undefined: |
| 156 | if foreign_key is Undefined: |
| 157 | raise RuntimeError("ondelete can only be used with foreign_key") |
| 158 | super().__init__(default=default, **kwargs) |
| 159 | self.primary_key = primary_key |
| 160 | self.nullable = nullable |
no outgoing calls
no test coverage detected
searching dependent graphs…