Skip to content

Commit 7a677af

Browse files
authored
refactor(java): add exception classes to java.nio.file (#360)
add supporting classes to java.util and java.lang
1 parent 8254d0a commit 7a677af

File tree

7 files changed

+306
-12
lines changed

7 files changed

+306
-12
lines changed

ignition-api-stubs/stubs/java/lang/__init__.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ class IllegalArgumentException(RuntimeException):
235235
self, message: Optional[str] = ..., cause: Optional[Throwable] = ...
236236
) -> None: ...
237237

238+
class IllegalStateException(RuntimeException):
239+
def __init__(
240+
self, message: Optional[str] = ..., cause: Optional[Throwable] = ...
241+
) -> None: ...
242+
238243
class IndexOutOfBoundsException(RuntimeException):
239244
def __init__(self, arg: Optional[Union[int, AnyStr]] = ...) -> None: ...
240245

ignition-api-stubs/stubs/java/nio/file/__init__.pyi

Lines changed: 99 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
from typing import Any, Iterator, List, Optional, Set, Union
22

33
from dev.coatl.helper.types import AnyStr
4-
from java.io import BufferedReader, BufferedWriter, InputStream, OutputStream
5-
from java.lang import AutoCloseable, CharSequence, Class, Enum, Object
4+
from java.io import (
5+
BufferedReader,
6+
BufferedWriter,
7+
InputStream,
8+
IOException,
9+
OutputStream,
10+
)
11+
from java.lang import (
12+
AutoCloseable,
13+
CharSequence,
14+
Class,
15+
Enum,
16+
IllegalArgumentException,
17+
IllegalStateException,
18+
Object,
19+
RuntimeException,
20+
Throwable,
21+
UnsupportedOperationException,
22+
)
623
from java.nio.channels import SeekableByteChannel
724
from java.nio.charset import Charset
825
from java.nio.file.attribute import (
@@ -14,6 +31,7 @@ from java.nio.file.attribute import (
1431
PosixFilePermission,
1532
UserPrincipal,
1633
)
34+
from java.util import ConcurrentModificationException
1735
from java.util.function import BiPredicate
1836
from java.util.stream import Stream
1937

@@ -39,6 +57,76 @@ class FileStore(Object):
3957
def supportsFileAttributeView(self, type: Class) -> bool: ...
4058
def type(self) -> AnyStr: ...
4159

60+
class ClosedDirectoryStreamException(IllegalStateException):
61+
def __init__(self) -> None: ...
62+
63+
class ClosedFileSystemException(IllegalStateException):
64+
def __init__(self) -> None: ...
65+
66+
class DirectoryIteratorException(ConcurrentModificationException):
67+
def __init__(self, cause: Throwable) -> None: ...
68+
69+
class FileSystemAlreadyExistsException(RuntimeException):
70+
def __init__(self, message: Optional[str] = ...) -> None: ...
71+
72+
class FileSystemException(IOException):
73+
def __init__(
74+
self,
75+
file: AnyStr,
76+
other: Optional[AnyStr] = ...,
77+
reason: Optional[AnyStr] = ...,
78+
) -> None: ...
79+
def getFile(self) -> AnyStr: ...
80+
def getOtherFile(self) -> Optional[AnyStr]: ...
81+
def getReason(self) -> Optional[AnyStr]: ...
82+
83+
class AccessDeniedException(FileSystemException):
84+
def __init__(
85+
self,
86+
file: AnyStr,
87+
other: Optional[AnyStr] = ...,
88+
reason: Optional[AnyStr] = ...,
89+
) -> None: ...
90+
91+
class AtomicMoveNotSupportedException(FileSystemException):
92+
def __init__(self, source: AnyStr, target: AnyStr, reason: AnyStr) -> None: ...
93+
94+
class DirectoryNotEmptyException(FileSystemException):
95+
def __init__(self, dir_: AnyStr) -> None: ...
96+
97+
class FileAlreadyExistsException(FileSystemException):
98+
def __init__(
99+
self,
100+
file: AnyStr,
101+
other: Optional[AnyStr] = ...,
102+
reason: Optional[AnyStr] = ...,
103+
) -> None: ...
104+
105+
class FileSystemLoopException(FileSystemException):
106+
def __init__(self, file: AnyStr) -> None: ...
107+
108+
class FileSystemNotFoundException(RuntimeException):
109+
def __init__(self, message: Optional[str] = ...) -> None: ...
110+
111+
class NoSuchFileException(FileSystemException):
112+
def __init__(
113+
self,
114+
file: AnyStr,
115+
other: Optional[AnyStr] = ...,
116+
reason: Optional[AnyStr] = ...,
117+
) -> None: ...
118+
119+
class NotDirectoryException(FileSystemException):
120+
def __init__(self, file: AnyStr) -> None: ...
121+
122+
class NotLinkException(FileSystemException):
123+
def __init__(
124+
self,
125+
file: AnyStr,
126+
other: Optional[AnyStr] = ...,
127+
reason: Optional[AnyStr] = ...,
128+
) -> None: ...
129+
42130
class FileVisitOption(Enum):
43131
FOLLOW_LINKS: FileVisitOption
44132
@staticmethod
@@ -160,6 +248,12 @@ class Files(Object):
160248
@staticmethod
161249
def writeString(path: Path, csq: CharSequence, *args: Any) -> Path: ...
162250

251+
class InvalidPathException(IllegalArgumentException):
252+
def __init__(self, input: str, reason: str, index: Optional[int] = ...) -> None: ...
253+
def getIndex(self) -> Optional[int]: ...
254+
def getInput(self) -> AnyStr: ...
255+
def getReason(self) -> AnyStr: ...
256+
163257
class LinkOption(Enum, CopyOption, OpenOption):
164258
NOFOLLOW_LINKS: LinkOption
165259
@staticmethod
@@ -196,6 +290,9 @@ class Paths(Object):
196290
@staticmethod
197291
def get(*args: Any) -> Path: ...
198292

293+
class ReadOnlyFileSystemException(UnsupportedOperationException):
294+
def __init__(self) -> None: ...
295+
199296
class StandardCopyOption(Enum, CopyOption, OpenOption):
200297
ATOMIC_MOVE: StandardCopyOption
201298
COPY_ATTRIBUTES: StandardCopyOption

ignition-api-stubs/stubs/java/util/__init__.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from typing import Any, Dict, Iterable, List, Mapping, Optional, Set, Union
22

33
from dev.coatl.helper.types import AnyStr
44
from java.io import InputStream, OutputStream
5-
from java.lang import Class, Object
5+
from java.lang import Class, Object, RuntimeException, Throwable
66
from java.nio import ByteBuffer
77
from java.time import Instant, ZoneId
88
from java.util.function import (
@@ -381,6 +381,11 @@ class Calendar(Object):
381381
def setWeekDate(self, weekYear: int, weekOfYear: int, dayOfWeek: int) -> None: ...
382382
def toInstant(self) -> Instant: ...
383383

384+
class ConcurrentModificationException(RuntimeException):
385+
def __init__(
386+
self, message: Optional[str] = ..., cause: Optional[Throwable] = ...
387+
) -> None: ...
388+
384389
class Currency(Object):
385390
@staticmethod
386391
def getAvailableCurrencies() -> Set[Currency]: ...

ignition-api/.pylintrc

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ prefer-stubs=no
9393

9494
# Minimum Python version to use for version dependent checks. Will default to
9595
# the version used to run pylint.
96-
py-version=3.13
96+
py-version=3.14
9797

9898
# Discover python modules and packages in the file system subtree.
9999
recursive=no
@@ -104,10 +104,6 @@ recursive=no
104104
# source root.
105105
source-roots=
106106

107-
# When enabled, pylint would attempt to guess common misconfiguration and emit
108-
# user-friendly hints instead of false-positive error messages.
109-
suggestion-mode=yes
110-
111107
# Allow loading of arbitrary C extensions. Extensions are imported into the
112108
# active Python interpreter and may run arbitrary code.
113109
unsafe-load-any-extension=no
@@ -229,6 +225,11 @@ name-group=
229225
# not require a docstring.
230226
no-docstring-rgx=^_
231227

228+
# Regular expression matching correct parameter specification variable names.
229+
# If left empty, parameter specification variable names will be checked with
230+
# the set naming style.
231+
#paramspec-rgx=
232+
232233
# List of decorators that produce properties, such as abc.abstractproperty. Add
233234
# to this list to register other decorators that produce valid properties.
234235
# These decorators are taken in consideration only for invalid-name.
@@ -242,6 +243,10 @@ property-classes=abc.abstractproperty
242243
# variable names will be checked with the set naming style.
243244
#typevar-rgx=
244245

246+
# Regular expression matching correct type variable tuple names. If left empty,
247+
# type variable tuple names will be checked with the set naming style.
248+
#typevartuple-rgx=
249+
245250
# Naming style matching correct variable names.
246251
variable-naming-style=any
247252

@@ -339,7 +344,9 @@ indent-after-paren=4
339344
# tab).
340345
indent-string=' '
341346

342-
# Maximum number of characters on a single line.
347+
# Maximum number of characters on a single line. Pylint's default of 100 is
348+
# based on PEP 8's guidance that teams may choose line lengths up to 99
349+
# characters.
343350
max-line-length=120
344351

345352
# Maximum number of lines in a module.
@@ -455,6 +462,9 @@ timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.
455462

456463
[MISCELLANEOUS]
457464

465+
# Whether or not to search for fixme's in docstrings.
466+
check-fixme-in-docstring=no
467+
458468
# List of note tags to take in consideration, separated by a comma.
459469
notes=FIXME,
460470
XXX,

ignition-api/src/java/lang/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"Enum",
1616
"Exception",
1717
"IllegalArgumentException",
18+
"IllegalStateException",
1819
"IndexOutOfBoundsException",
1920
"Iterable",
2021
"NullPointerException",
@@ -796,6 +797,16 @@ def __init__(self, message=None, cause=None):
796797
super(IllegalArgumentException, self).__init__(message, cause)
797798

798799

800+
class IllegalStateException(RuntimeException):
801+
"""Signals that a method has been invoked at an illegal or
802+
inappropriate time.
803+
"""
804+
805+
def __init__(self, message=None, cause=None):
806+
# type: (Optional[str], Optional[Throwable]) -> None
807+
super(IllegalStateException, self).__init__(message, cause)
808+
809+
799810
class IndexOutOfBoundsException(RuntimeException):
800811
"""Thrown to indicate that an index of some sort (such as to an
801812
array, to a string, or to a vector) is out of range.

0 commit comments

Comments
 (0)