Skip to content

Commit 38022fd

Browse files
authored
[style] Fix init isort and align makefile and CI (#43260)
* add other folders to CI style check * fix init_sort * match the rules * improve * date * oupsi revert * fix doc
1 parent e977446 commit 38022fd

8 files changed

Lines changed: 36 additions & 27 deletions

File tree

.circleci/config.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,10 @@ jobs:
154154
command: pip freeze | tee installed.txt
155155
- store_artifacts:
156156
path: ~/transformers/installed.txt
157-
- run: python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1)
158-
- run: ruff check examples tests src utils
159-
- run: ruff format examples tests src utils --check
157+
- run: ruff check examples tests src utils scripts benchmark benchmark_v2 setup.py conftest.py
158+
- run: ruff format --check examples tests src utils scripts benchmark benchmark_v2 setup.py conftest.py
160159
- run: python utils/custom_init_isort.py --check_only
161160
- run: python utils/sort_auto_mappings.py --check_only
162-
- run: python utils/check_doc_toc.py
163-
- run: python utils/check_docstrings.py --check_all
164161

165162
check_repository_consistency:
166163
working_directory: ~/transformers
@@ -179,8 +176,11 @@ jobs:
179176
command: pip freeze | tee installed.txt
180177
- store_artifacts:
181178
path: ~/transformers/installed.txt
179+
- run: python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1)
182180
- run: python utils/check_copies.py
183181
- run: python utils/check_modular_conversion.py
182+
- run: python utils/check_doc_toc.py
183+
- run: python utils/check_docstrings.py
184184
- run: python utils/check_dummies.py
185185
- run: python utils/check_repo.py
186186
- run: python utils/check_modeling_structure.py
@@ -189,13 +189,13 @@ jobs:
189189
- run: python utils/check_config_docstrings.py
190190
- run: python utils/check_config_attributes.py
191191
- run: python utils/check_doctest_list.py
192+
- run: python utils/update_metadata.py --check-only
193+
- run: python utils/add_dates.py --check-only
192194
- run: >
193195
md5sum src/transformers/dependency_versions_table.py > md5sum.saved;
194196
python setup.py deps_table_update;
195-
md5sum -c --quiet md5sum.saved || (printf "\nError: the version dependency table is outdated.\nPlease run 'make style' and commit the changes.\n\n" && exit 1);
197+
md5sum -c --quiet md5sum.saved || (printf "Error: the version dependency table is outdated.\nPlease run 'make fix-repo' and commit the changes.\n" && exit 1);
196198
rm md5sum.saved
197-
- run: python utils/update_metadata.py --check-only
198-
- run: python utils/check_docstrings.py
199199
200200
workflows:
201201
version: 2

Makefile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@ exclude_folders := ""
1111
style:
1212
ruff check $(check_dirs) setup.py conftest.py --fix --exclude $(exclude_folders)
1313
ruff format $(check_dirs) setup.py conftest.py --exclude $(exclude_folders)
14-
python setup.py deps_table_update
14+
python utils/custom_init_isort.py
1515
python utils/sort_auto_mappings.py
16-
python utils/check_doc_toc.py --fix_and_overwrite
1716

1817

19-
# Check that the repo is in a good state
18+
# Check that the repo is in a good state (both style and consistency CI checks)
2019
# Note: each line is run in its own shell, and doing `-` before the command ignores the errors if any, continuing with next command
2120
check-repo:
2221
ruff check $(check_dirs) setup.py conftest.py
2322
ruff format --check $(check_dirs) setup.py conftest.py
24-
python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1)
23+
-python utils/custom_init_isort.py --check_only
2524
-python utils/sort_auto_mappings.py --check_only
26-
-python utils/check_doc_toc.py
25+
-python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1)
2726
-python utils/check_copies.py
2827
-python utils/check_modular_conversion.py
28+
-python utils/check_doc_toc.py
29+
-python utils/check_docstrings.py
2930
-python utils/check_dummies.py
3031
-python utils/check_repo.py
3132
-python utils/check_modeling_structure.py
@@ -34,14 +35,21 @@ check-repo:
3435
-python utils/check_config_docstrings.py
3536
-python utils/check_config_attributes.py
3637
-python utils/check_doctest_list.py
37-
-python utils/update_metadata.py --check-only
38-
-python utils/check_docstrings.py
39-
-python utils/add_dates.py --check-only
38+
-python utils/update_metadata.py --check-only
39+
-python utils/add_dates.py --check-only
40+
-@{ \
41+
md5sum src/transformers/dependency_versions_table.py > md5sum.saved; \
42+
python setup.py deps_table_update; \
43+
md5sum -c --quiet md5sum.saved || (printf "Error: the version dependency table is outdated.\nPlease run 'make fix-repo' and commit the changes.\n" && exit 1); \
44+
rm md5sum.saved; \
45+
}
4046

4147

4248
# Run all repo checks for which there is an automatic fix, most notably modular conversions
4349
# Note: each line is run in its own shell, and doing `-` before the command ignores the errors if any, continuing with next command
4450
fix-repo: style
51+
-python setup.py deps_table_update
52+
-python utils/check_doc_toc.py --fix_and_overwrite
4553
-python utils/check_copies.py --fix_and_overwrite
4654
-python utils/check_modular_conversion.py --fix_and_overwrite
4755
-python utils/check_dummies.py --fix_and_overwrite

docs/source/en/model_doc/minimax_m2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer.
1717
1818
-->
19+
*This model was released on {release_date} and added to Hugging Face Transformers on 2026-01-09.*
1920

2021

2122
# MiniMax-M2

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def run(self):
212212
content = [
213213
"# THIS FILE HAS BEEN AUTOGENERATED. To update:",
214214
"# 1. modify the `_deps` dict in setup.py",
215-
"# 2. run `make style``",
215+
"# 2. run `make fix-repo``",
216216
"deps = {",
217217
entries,
218218
"}",

src/transformers/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@
178178
"testing_utils": [],
179179
"tokenization_python": ["PreTrainedTokenizer", "PythonBackend"],
180180
"tokenization_utils": [],
181-
"tokenization_utils_fast": [],
182-
"tokenization_utils_sentencepiece": ["SentencePieceBackend"],
183181
"tokenization_utils_base": [
184182
"AddedToken",
185183
"BatchEncoding",
186184
"CharSpan",
187185
"PreTrainedTokenizerBase",
188186
"TokenSpan",
189187
],
188+
"tokenization_utils_fast": [],
189+
"tokenization_utils_sentencepiece": ["SentencePieceBackend"],
190190
"trainer_callback": [
191191
"DefaultFlowCallback",
192192
"EarlyStoppingCallback",
@@ -243,6 +243,8 @@
243243
"is_vision_available",
244244
"logging",
245245
],
246+
"utils.import_utils": ["requires_backends"],
247+
"utils.kernel_config": ["KernelConfig"],
246248
"utils.quantization_config": [
247249
"AqlmConfig",
248250
"AutoRoundConfig",
@@ -253,20 +255,18 @@
253255
"EetqConfig",
254256
"FbgemmFp8Config",
255257
"FineGrainedFP8Config",
258+
"FPQuantConfig",
256259
"GPTQConfig",
257260
"HiggsConfig",
258261
"HqqConfig",
259262
"Mxfp4Config",
260263
"QuantoConfig",
261264
"QuarkConfig",
262-
"FPQuantConfig",
263265
"SpQRConfig",
264266
"TorchAoConfig",
265267
"VptqConfig",
266268
],
267269
"video_utils": [],
268-
"utils.kernel_config": ["KernelConfig"],
269-
"utils.import_utils": ["requires_backends"],
270270
}
271271

272272
# tokenizers-backed objects
@@ -282,8 +282,8 @@
282282
else:
283283
# Fast tokenizers structure
284284
_import_structure["tokenization_utils_tokenizers"] = [
285-
"TokenizersBackend",
286285
"PreTrainedTokenizerFast",
286+
"TokenizersBackend",
287287
]
288288

289289

@@ -386,6 +386,7 @@
386386
"EncoderRepetitionPenaltyLogitsProcessor",
387387
"EosTokenCriteria",
388388
"EpsilonLogitsWarper",
389+
"MinPLogitsWarper",
389390
"EtaLogitsWarper",
390391
"ExponentialDecayLengthPenalty",
391392
"ForcedBOSTokenLogitsProcessor",
@@ -399,7 +400,6 @@
399400
"MaxTimeCriteria",
400401
"MinLengthLogitsProcessor",
401402
"MinNewTokensLengthLogitsProcessor",
402-
"MinPLogitsWarper",
403403
"NoBadWordsLogitsProcessor",
404404
"NoRepeatNGramLogitsProcessor",
405405
"PrefixConstrainedLogitsProcessor",

src/transformers/dependency_versions_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE HAS BEEN AUTOGENERATED. To update:
22
# 1. modify the `_deps` dict in setup.py
3-
# 2. run `make style``
3+
# 2. run `make fix-repo``
44
deps = {
55
"Pillow": "Pillow>=10.0.1,<=15.0",
66
"accelerate": "accelerate>=1.1.0",

utils/check_doc_toc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
python utils/check_doc_toc.py
2424
```
2525
26-
Auto-sort the table of content if it is not properly sorted (used in `make style`):
26+
Auto-sort the table of content if it is not properly sorted (used in `make fix-repo`):
2727
2828
```bash
2929
python utils/check_doc_toc.py --fix_and_overwrite

utils/custom_init_isort.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def sort_imports(file: str, check_only: bool = True):
244244
code = f.read()
245245

246246
# If the file is not a custom init, there is nothing to do.
247-
if "_import_structure" not in code or "define_import_structure" in code:
247+
if "_import_structure = {" not in code:
248248
return
249249

250250
# Blocks of indent level 0

0 commit comments

Comments
 (0)