""" Copyright 2020 Inmanta Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Contact: code@inmanta.com"""fromenumimportEnumfromtypingimportOptionalfrompydanticimportBaseModel,ConfigDictfrominmanta.stable_apiimportstable_api# can't inherit from ABC because it breaks __slots__ of child classes in Python 3.6classExportable:# explicitly set empty slots so child classes are allowed to use __slots____slots__=()defexport(self)->BaseModel:raiseNotImplementedError()
[docs]@stable_apiclassPosition(BaseModel):""" Position in a file. Based on the `LSP spec 3.15 <https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#position>`__ """line:intcharacter:int
[docs]@stable_apiclassRange(BaseModel):""" Range in a file. Based on the `LSP spec 3.15 <https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#range>`__ """start:Positionend:Position
[docs]@stable_apiclassLocation(BaseModel):""" Location in a file. Based on the `LSP spec 3.15 <https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#location>`__ """uri:strrange:Range
[docs]@stable_apiclassErrorCategory(str,Enum):""" Category of an error. """plugin="plugin_exception"""" A plugin explicitly raised an :py:class:`inmanta.plugins.PluginException`. """parser="parse_error"""" Error occurred while parsing. """runtime="runtime_error"""" Error occurred after parsing. """
[docs]@stable_apiclassError(BaseModel):""" Error occurred while trying to compile. """category:ErrorCategory=ErrorCategory.runtime""" Category of this error. """type:str""" Fully qualified name of the actual exception. """message:str""" Error message. """location:Optional[Location]=None""" Location where this error occurred. """# allow additional fields to be set for exception types that require itmodel_config=ConfigDict(extra="allow",validate_assignment=True)