mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 11:56:05 +08:00
Add typing for file and settings.
Add diagnostic generator documentation
This commit is contained in:
parent
f49f8b3cb8
commit
d19f1f3e42
@ -7,7 +7,7 @@ from .linters.diagnostic_generator import DiagnosticGenerator
|
|||||||
from .linters.meshes import Meshes
|
from .linters.meshes import Meshes
|
||||||
|
|
||||||
|
|
||||||
def create(file: Path, settings) -> Optional[DiagnosticGenerator]:
|
def create(file: Path, settings: dict) -> Optional[DiagnosticGenerator]:
|
||||||
""" Returns a DiagnosticGenerator depending on the file format """
|
""" Returns a DiagnosticGenerator depending on the file format """
|
||||||
if not file.exists():
|
if not file.exists():
|
||||||
return None
|
return None
|
||||||
|
@ -9,7 +9,7 @@ from ..replacement import Replacement
|
|||||||
|
|
||||||
|
|
||||||
class Definition(DiagnosticGenerator):
|
class Definition(DiagnosticGenerator):
|
||||||
def __init__(self, file, settings) -> None:
|
def __init__(self, file: Path, settings: dict) -> None:
|
||||||
super().__init__(file, settings)
|
super().__init__(file, settings)
|
||||||
self._defs = {}
|
self._defs = {}
|
||||||
self._getDefs(file)
|
self._getDefs(file)
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
from pathlib import Path
|
||||||
from typing import Iterator
|
from typing import Iterator
|
||||||
|
|
||||||
from ..diagnostic import Diagnostic
|
from ..diagnostic import Diagnostic
|
||||||
|
|
||||||
|
|
||||||
class DiagnosticGenerator(ABC):
|
class DiagnosticGenerator(ABC):
|
||||||
def __init__(self, file, settings) -> None:
|
def __init__(self, file: Path, settings: dict) -> None:
|
||||||
|
""" Yields Diagnostics for file, these are suggested text replacements based on formatting rules in settings.
|
||||||
|
|
||||||
|
@param file: A file to generate diagnostics for
|
||||||
|
@param settings: A list of settings containing rules for creating diagnostics
|
||||||
|
"""
|
||||||
self._settings = settings
|
self._settings = settings
|
||||||
self._file = file
|
self._file = file
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from pathlib import Path
|
||||||
from typing import Iterator
|
from typing import Iterator
|
||||||
|
|
||||||
from ..diagnostic import Diagnostic
|
from ..diagnostic import Diagnostic
|
||||||
@ -5,7 +6,7 @@ from .diagnostic_generator import DiagnosticGenerator
|
|||||||
|
|
||||||
|
|
||||||
class Meshes(DiagnosticGenerator):
|
class Meshes(DiagnosticGenerator):
|
||||||
def __init__(self, file, settings) -> None:
|
def __init__(self, file: Path, settings: dict) -> None:
|
||||||
super().__init__(file, settings)
|
super().__init__(file, settings)
|
||||||
self._max_file_size = self._settings.get("diagnostic-mesh-file-size", 1e6)
|
self._max_file_size = self._settings.get("diagnostic-mesh-file-size", 1e6)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user