Closed willfrey closed 3 years ago
cc @Narsil
Definitely not intentional, it's pretty bad as you mention. Opened a PR for this.
@LysandreJik pylint
is able to detect those and many are found throughout the library.
Is it something we want to start checking automatically and enforcing not to have, they are more likely to hurt than to help. Didn't put everything here
src/transformers/debug_utils.py:136:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/tapas/configuration_tapas.py:145:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/beit/configuration_beit.py:111:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/beit/configuration_beit.py:111:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
^[:src/transformers/models/camembert/tokenization_camembert.py:113:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/camembert/tokenization_camembert_fast.py:106:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/gpt_neo/configuration_gpt_neo.py:100:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/fsmt/configuration_fsmt.py:130:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/reformer/configuration_reformer.py:163:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/reformer/configuration_reformer.py:163:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/reformer/configuration_reformer.py:163:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/reformer/tokenization_reformer.py:92:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/reformer/tokenization_reformer_fast.py:88:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/segformer/configuration_segformer.py:100:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/segformer/configuration_segformer.py:100:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/segformer/configuration_segformer.py:100:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/segformer/configuration_segformer.py:100:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/segformer/configuration_segformer.py:100:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/segformer/configuration_segformer.py:100:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/segformer/configuration_segformer.py:100:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/segformer/configuration_segformer.py:100:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/marian/convert_marian_to_pytorch.py:206:0: W0102: Dangerous default value {} as argument (dangerous-default-value)
src/transformers/models/funnel/configuration_funnel.py:110:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py:165:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py:165:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py:165:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py:114:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py:114:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py:114:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutlmv2/configuration_layoutlmv2.py:120:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/transfo_xl/configuration_transfo_xl.py:116:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/transfo_xl/tokenization_transfo_xl.py:156:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutxlm/tokenization_layoutxlm.py:126:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutxlm/tokenization_layoutxlm.py:126:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutxlm/tokenization_layoutxlm.py:126:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutxlm/tokenization_layoutxlm_fast.py:115:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutxlm/tokenization_layoutxlm_fast.py:115:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/layoutxlm/tokenization_layoutxlm_fast.py:115:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/visual_bert/convert_visual_bert_original_pytorch_checkpoint_to_pytorch.py:64:0: W0102: Dangerous default value rename_keys_prefix (builtins.list) as argument (dangerous-default-value)
src/transformers/models/xlnet/tokenization_xlnet.py:127:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
src/transformers/models/xlnet/tokenization_xlnet_fast.py:125:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
https://github.com/huggingface/transformers/blob/a14d62b0b11e6cb0c64059606e4f8dbf78e40e41/src/transformers/pipelines/__init__.py#L311
Is this intentional? I noticed the default is an empty dict but inspecting the signature in an interactive session showed that the dictionary was mutated:
This can cause some headaches because the default value references the same dict object all the time.