Skip to content

Commit

Permalink
Added type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlegiantJGC committed Feb 15, 2024
1 parent bc6d687 commit 9fa1cb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/amulet_nbt/_nbt_encoding/_string/read_snbt.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re

import amulet_nbt
from amulet_nbt._errors import SNBTParseError
from amulet_nbt._tag.abc cimport AbstractBaseTag
from amulet_nbt._tag.int cimport ByteTag, ShortTag, IntTag, LongTag
Expand Down Expand Up @@ -207,7 +208,13 @@ cdef tuple _parse_snbt_recursive(unicode snbt, int index=0):

return data, index

cpdef AbstractBaseTag from_snbt(unicode snbt):
def from_snbt(unicode snbt: str) -> amulet_nbt.AbstractBaseTag:
"""Parse Stringified NBT.

:param snbt: The SNBT string to parse.
:return: The tag
:raises: SNBTParseError if the SNBT format is invalid.
"""
try:
return _parse_snbt_recursive(snbt)[0]
except SNBTParseError as e:
Expand Down
4 changes: 2 additions & 2 deletions src/amulet_nbt/_string_encoding/encoding.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ from ._cpp.mutf8 cimport (


cdef class StringEncoding:
def encode(self, bytes data) -> bytes:
def encode(self, bytes data: bytes) -> bytes:
return self.encode_cpp(data)

def decode(self, bytes data) -> bytes:
def decode(self, bytes data: bytes) -> bytes:
return self.decode_cpp(data)


Expand Down

0 comments on commit 9fa1cb5

Please sign in to comment.