Skip to content

Commit 7339b36

Browse files
committed
Add argument data type checking for 23 functions:
- cell_name_to_coordinates - column_name_to_number - column_number_to_name - coordinates_to_cell_name - open_file - open_reader - set_row_height - set_row_outline_level - set_row_style - set_row_visible - set_sheet_background - set_sheet_background_from_bytes - set_sheet_col - set_sheet_dimension - set_sheet_name - set_sheet_props - set_sheet_row - set_sheet_view - set_sheet_visible - set_workbook_props - unmerge_cell - unprotect_sheet - unprotect_workbook - Upgrade build tool chain version
1 parent e616625 commit 7339b36

File tree

3 files changed

+283
-6
lines changed

3 files changed

+283
-6
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
test:
1010
strategy:
1111
matrix:
12-
go-version: [1.24.x]
12+
go-version: [1.25.x]
1313
os: [ubuntu-24.04, macos-latest, windows-latest]
1414
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1515
targetplatform: [x64]
@@ -110,9 +110,9 @@ jobs:
110110
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
111111
brew tap messense/macos-cross-toolchains
112112
brew install FiloSottile/musl-cross/musl-cross mingw-w64
113-
wget https://github.com/mstorsjo/llvm-mingw/releases/download/20250613/llvm-mingw-20250613-ucrt-macos-universal.tar.xz
114-
tar -xzf llvm-mingw-20250613-ucrt-macos-universal.tar.xz
115-
export PATH="$(pwd)/llvm-mingw-20250613-ucrt-macos-universal/bin:$PATH"
113+
wget https://github.com/mstorsjo/llvm-mingw/releases/download/20250709/llvm-mingw-20250709-ucrt-macos-universal.tar.xz
114+
tar -xzf llvm-mingw-20250709-ucrt-macos-universal.tar.xz
115+
export PATH="$(pwd)/llvm-mingw-20250709-ucrt-macos-universal/bin:$PATH"
116116
CC=aarch64-linux-musl-gcc GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.arm64.linux.so main.go
117117
CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.amd64.windows.dll main.go
118118
CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.386.windows.dll main.go

excelize.py

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4939,6 +4939,14 @@ def set_row_height(self, sheet: str, row: int, height: float) -> None:
49394939
print(err)
49404940
```
49414941
"""
4942+
prepare_args(
4943+
[sheet, row, height],
4944+
[
4945+
argsRule("sheet", [str]),
4946+
argsRule("row", [int]),
4947+
argsRule("height", [float]),
4948+
],
4949+
)
49424950
lib.SetRowHeight.restype = c_char_p
49434951
err = lib.SetRowHeight(
49444952
self.file_index, sheet.encode(ENCODE), c_int(row), c_double(height)
@@ -4970,6 +4978,14 @@ def set_row_outline_level(self, sheet: str, row: int, level: int) -> None:
49704978
print(err)
49714979
```
49724980
"""
4981+
prepare_args(
4982+
[sheet, row, level],
4983+
[
4984+
argsRule("sheet", [str]),
4985+
argsRule("row", [int]),
4986+
argsRule("level", [int]),
4987+
],
4988+
)
49734989
lib.SetRowOutlineLevel.restype = c_char_p
49744990
err = lib.SetRowOutlineLevel(
49754991
self.file_index, sheet.encode(ENCODE), c_int(row), c_int(level)
@@ -5012,6 +5028,15 @@ def set_row_style(self, sheet: str, start: int, end: int, style_id: int) -> None
50125028
print(err)
50135029
```
50145030
"""
5031+
prepare_args(
5032+
[sheet, start, end, style_id],
5033+
[
5034+
argsRule("sheet", [str]),
5035+
argsRule("start", [int]),
5036+
argsRule("end", [int]),
5037+
argsRule("style_id", [int]),
5038+
],
5039+
)
50155040
lib.SetRowStyle.restype = c_char_p
50165041
err = lib.SetRowStyle(
50175042
self.file_index,
@@ -5047,6 +5072,14 @@ def set_row_visible(self, sheet: str, row: int, visible: bool) -> None:
50475072
print(err)
50485073
```
50495074
"""
5075+
prepare_args(
5076+
[sheet, row, visible],
5077+
[
5078+
argsRule("sheet", [str]),
5079+
argsRule("row", [int]),
5080+
argsRule("visible", [bool]),
5081+
],
5082+
)
50505083
lib.SetRowVisible.restype = c_char_p
50515084
err = lib.SetRowVisible(
50525085
self.file_index,
@@ -5071,6 +5104,10 @@ def set_sheet_background(self, sheet: str, picture: str) -> None:
50715104
None: Return None if no error occurred, otherwise raise a
50725105
RuntimeError with the message.
50735106
"""
5107+
prepare_args(
5108+
[sheet, picture],
5109+
[argsRule("sheet", [str]), argsRule("picture", [str])],
5110+
)
50745111
lib.SetSheetBackground.restype = c_char_p
50755112
err = lib.SetSheetBackground(
50765113
self.file_index,
@@ -5097,6 +5134,14 @@ def set_sheet_background_from_bytes(
50975134
None: Return None if no error occurred, otherwise raise a
50985135
RuntimeError with the message.
50995136
"""
5137+
prepare_args(
5138+
[sheet, extension, picture],
5139+
[
5140+
argsRule("sheet", [str]),
5141+
argsRule("extension", [str]),
5142+
argsRule("picture", [bytes]),
5143+
],
5144+
)
51005145
lib.SetSheetBackgroundFromBytes.restype = c_char_p
51015146
err = lib.SetSheetBackgroundFromBytes(
51025147
self.file_index,
@@ -5139,6 +5184,14 @@ def set_sheet_col(
51395184
print(err)
51405185
```
51415186
"""
5187+
prepare_args(
5188+
[sheet, cell, values],
5189+
[
5190+
argsRule("sheet", [str]),
5191+
argsRule("cell", [str]),
5192+
argsRule("values", [list]),
5193+
],
5194+
)
51425195
lib.SetSheetCol.restype = c_char_p
51435196
vals = (types_go._Interface * len(values))()
51445197
for i, value in enumerate(values):
@@ -5169,6 +5222,10 @@ def set_sheet_dimension(self, sheet: str, range_ref: str) -> None:
51695222
None: Return None if no error occurred, otherwise raise a
51705223
RuntimeError with the message.
51715224
"""
5225+
prepare_args(
5226+
[sheet, range_ref],
5227+
[argsRule("sheet", [str]), argsRule("range_ref", [str])],
5228+
)
51725229
lib.SetSheetDimension.restype = c_char_p
51735230
err = lib.SetSheetDimension(
51745231
self.file_index,
@@ -5194,6 +5251,10 @@ def set_sheet_name(self, source: str, target: str) -> None:
51945251
None: Return None if no error occurred, otherwise raise a
51955252
RuntimeError with the message.
51965253
"""
5254+
prepare_args(
5255+
[source, target],
5256+
[argsRule("source", [str]), argsRule("target", [str])],
5257+
)
51975258
lib.SetSheetName.restype = c_char_p
51985259
err = lib.SetSheetName(
51995260
self.file_index,
@@ -5215,6 +5276,10 @@ def set_sheet_props(self, sheet: str, opts: SheetPropsOptions) -> None:
52155276
None: Return None if no error occurred, otherwise raise a
52165277
RuntimeError with the message.
52175278
"""
5279+
prepare_args(
5280+
[sheet, opts],
5281+
[argsRule("sheet", [str]), argsRule("opts", [SheetPropsOptions])],
5282+
)
52185283
lib.SetSheetProps.restype = c_char_p
52195284
options = py_value_to_c(opts, types_go._SheetPropsOptions())
52205285
err = lib.SetSheetProps(
@@ -5254,6 +5319,14 @@ def set_sheet_row(
52545319
print(err)
52555320
```
52565321
"""
5322+
prepare_args(
5323+
[sheet, cell, values],
5324+
[
5325+
argsRule("sheet", [str]),
5326+
argsRule("cell", [str]),
5327+
argsRule("values", [list]),
5328+
],
5329+
)
52575330
lib.SetSheetRow.restype = c_char_p
52585331
vals = (types_go._Interface * len(values))()
52595332
for i, value in enumerate(values):
@@ -5282,6 +5355,14 @@ def set_sheet_view(self, sheet: str, view_index: int, opts: ViewOptions) -> None
52825355
None: Return None if no error occurred, otherwise raise a
52835356
RuntimeError with the message.
52845357
"""
5358+
prepare_args(
5359+
[sheet, view_index, opts],
5360+
[
5361+
argsRule("sheet", [str]),
5362+
argsRule("view_index", [int]),
5363+
argsRule("opts", [ViewOptions]),
5364+
],
5365+
)
52855366
lib.SetSheetView.restype = c_char_p
52865367
options = py_value_to_c(opts, types_go._ViewOptions())
52875368
err = lib.SetSheetView(
@@ -5313,6 +5394,14 @@ def set_sheet_visible(self, sheet: str, visible: bool, *very_hidden: bool) -> No
53135394
f.set_sheet_visible("Sheet1", False)
53145395
```
53155396
"""
5397+
prepare_args(
5398+
[sheet, visible, very_hidden[0]] if very_hidden else [sheet, visible],
5399+
[
5400+
argsRule("sheet", [str]),
5401+
argsRule("visible", [bool]),
5402+
argsRule("very_hidden", [bool], True),
5403+
],
5404+
)
53165405
lib.SetSheetVisible.restype = c_char_p
53175406
vh = False
53185407
if len(very_hidden) > 0:
@@ -5334,6 +5423,7 @@ def set_workbook_props(self, opts: WorkbookPropsOptions) -> None:
53345423
None: Return None if no error occurred, otherwise raise a
53355424
RuntimeError with the message.
53365425
"""
5426+
prepare_args([opts], [argsRule("opts", [WorkbookPropsOptions])])
53375427
lib.SetWorkbookProps.restype = c_char_p
53385428
options = py_value_to_c(opts, types_go._WorkbookPropsOptions())
53395429
err = lib.SetWorkbookProps(self.file_index, byref(options)).decode(ENCODE)
@@ -5378,6 +5468,14 @@ def unmerge_cell(
53785468
print(err)
53795469
```
53805470
"""
5471+
prepare_args(
5472+
[sheet, top_left_cell, bottom_right_cell],
5473+
[
5474+
argsRule("sheet", [str]),
5475+
argsRule("top_left_cell", [str]),
5476+
argsRule("bottom_right_cell", [str]),
5477+
],
5478+
)
53815479
lib.UnmergeCell.restype = c_char_p
53825480
err = lib.UnmergeCell(
53835481
self.file_index,
@@ -5401,6 +5499,10 @@ def unprotect_sheet(self, sheet: str, *password: str) -> None:
54015499
None: Return None if no error occurred, otherwise raise a
54025500
RuntimeError with the message.
54035501
"""
5502+
prepare_args(
5503+
[sheet, password[0]] if password else [sheet],
5504+
[argsRule("sheet", [str]), argsRule("password", [str], True)],
5505+
)
54045506
lib.UnprotectSheet.restype = c_char_p
54055507
passwd = password[0] if len(password) > 0 else ""
54065508
err = lib.UnprotectSheet(
@@ -5425,6 +5527,10 @@ def unprotect_workbook(self, *password: str) -> None:
54255527
None: Return None if no error occurred, otherwise raise a
54265528
RuntimeError with the message.
54275529
"""
5530+
prepare_args(
5531+
[password[0]] if password else [],
5532+
[argsRule("password", [str], True)],
5533+
)
54285534
lib.UnprotectWorkbook.restype = c_char_p
54295535
passwd = password[0] if len(password) > 0 else ""
54305536
err = lib.UnprotectWorkbook(
@@ -5464,6 +5570,7 @@ def cell_name_to_coordinates(cell: str) -> Tuple[int, int]:
54645570
Tuple[int, int]: Return a tuple containing the column number, row number
54655571
if no error occurred, otherwise raise a RuntimeError with the message.
54665572
"""
5573+
prepare_args([cell], [argsRule("cell", [str])])
54675574
lib.CellNameToCoordinates.restype = types_go._CellNameToCoordinatesResult
54685575
res = lib.CellNameToCoordinates(cell.encode(ENCODE))
54695576
err = res.err.decode(ENCODE)
@@ -5484,6 +5591,7 @@ def column_name_to_number(name: str) -> int:
54845591
int: Return the column number as a integer if no error occurred,
54855592
otherwise raise a RuntimeError with the message.
54865593
"""
5594+
prepare_args([name], [argsRule("name", [str])])
54875595
lib.ColumnNameToNumber.restype = types_go._IntErrorResult
54885596
res = lib.ColumnNameToNumber(name.encode(ENCODE))
54895597
err = res.err.decode(ENCODE)
@@ -5503,6 +5611,7 @@ def column_number_to_name(num: int) -> str:
55035611
str: Return the column name as a string if no error occurred, otherwise
55045612
raise a RuntimeError with the message.
55055613
"""
5614+
prepare_args([num], [argsRule("num", [int])])
55065615
lib.ColumnNumberToName.restype = types_go._StringErrorResult
55075616
res = lib.ColumnNumberToName(c_int(num))
55085617
err = res.err.decode(ENCODE)
@@ -5526,6 +5635,14 @@ def coordinates_to_cell_name(col: int, row: int, *is_absolute: bool) -> str:
55265635
str: Return the cell name as a string if no error occurred, otherwise
55275636
raise a RuntimeError with the message.
55285637
"""
5638+
prepare_args(
5639+
[col, row, is_absolute[0]] if is_absolute else [col, row],
5640+
[
5641+
argsRule("col", [int]),
5642+
argsRule("row", [int]),
5643+
argsRule("is_absolute", [bool], True),
5644+
],
5645+
)
55295646
lib.CoordinatesToCellName.restype = types_go._StringErrorResult
55305647
options = False
55315648
if len(is_absolute) > 0:
@@ -5560,6 +5677,13 @@ def open_file(filename: str, *opts: Options) -> File:
55605677
File: Return a File object if if no error occurred, otherwise raise a
55615678
RuntimeError with the message.
55625679
"""
5680+
prepare_args(
5681+
[filename, opts[0]] if opts else [filename],
5682+
[
5683+
argsRule("filename", [str]),
5684+
argsRule("opts", [Options], True),
5685+
],
5686+
)
55635687
lib.OpenFile.restype, options = types_go._IntErrorResult, None
55645688
if len(opts) > 0:
55655689
options = byref(py_value_to_c(opts[0], types_go._Options()))
@@ -5582,6 +5706,13 @@ def open_reader(buffer: bytes, *opts: Options) -> Optional[File]:
55825706
Tuple[Optional[File], Optional[Exception]]: A tuple containing a File
55835707
object if successful, or None and an Exception if an error occurred.
55845708
"""
5709+
prepare_args(
5710+
[buffer, opts[0]] if opts else [buffer],
5711+
[
5712+
argsRule("buffer", [bytes]),
5713+
argsRule("opts", [Options], True),
5714+
],
5715+
)
55855716
lib.OpenReader.restype, options = types_go._IntErrorResult, None
55865717
if len(opts) > 0:
55875718
options = byref(py_value_to_c(opts[0], types_go._Options()))

0 commit comments

Comments
 (0)