Gh3275: sample_missing_splits in SST-2 #1940
Annotations
10 errors
test:
flair/data.py#L341
ruff
pytest_ruff.RuffError: flair/data.py:42:15: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple`
|
42 | BoundingBox = namedtuple("BoundingBox", ["left", "top", "right", "bottom"])
| ^^^^^^^^^^ PYI024
|
= help: Replace with `typing.NamedTuple`
flair/data.py:730:14: E721 Do not compare types, use `isinstance()`
|
728 | tokenizer = use_tokenizer
729 |
730 | elif type(use_tokenizer) == bool:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721
731 | tokenizer = SegtokTokenizer() if use_tokenizer else SpaceTokenizer()
|
flair/data.py:812:12: E721 Do not compare types, use `isinstance()`
|
810 | assert token.sentence is None
811 |
812 | if type(token) is str:
| ^^^^^^^^^^^^^^^^^^ E721
813 | token = Token(token)
814 | token = cast(Token, token)
|
|
test:
flair/tokenization.py#L1
Black format check
--- /home/runner/work/flair/flair/flair/tokenization.py 2023-08-09 09:47:41.291888 +0000
+++ /home/runner/work/flair/flair/flair/tokenization.py 2023-08-09 09:53:47.235342 +0000
@@ -254,13 +254,13 @@
r"x", # added this special x character to tokenize it separately
r"[\(\)\[\]\{\}]", # want to split at every bracket
r"/", # want to split at every slash
r"(?<=[0-9])[+\-\*^](?=[0-9-])",
rf"(?<=[{char_classes.ALPHA_LOWER}])\.(?=[{char_classes.ALPHA_UPPER}])",
- fr"(?<=[{char_classes.ALPHA}]),(?=[{char_classes.ALPHA}])",
- fr'(?<=[{char_classes.ALPHA}])[?";:=,.]*(?:{char_classes.HYPHENS})(?=[{char_classes.ALPHA}])',
- fr"(?<=[{char_classes.ALPHA}0-9])[:<>=/](?=[{char_classes.ALPHA}])",
+ rf"(?<=[{char_classes.ALPHA}]),(?=[{char_classes.ALPHA}])",
+ rf'(?<=[{char_classes.ALPHA}])[?";:=,.]*(?:{char_classes.HYPHENS})(?=[{char_classes.ALPHA}])',
+ rf"(?<=[{char_classes.ALPHA}0-9])[:<>=/](?=[{char_classes.ALPHA}])",
]
)
prefix_re = spacy.util.compile_prefix_regex(combined_rule_prefixes())
infix_re = spacy.util.compile_infix_regex(infixes)
|
test:
flair/training_utils.py#L341
ruff
pytest_ruff.RuffError: flair/training_utils.py:102:12: E721 Do not compare types, use `isinstance()`
|
100 | class WeightExtractor:
101 | def __init__(self, directory: Union[str, Path], number_of_weights: int = 10) -> None:
102 | if type(directory) is str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
103 | directory = Path(directory)
104 | self.weights_file = init_output_file(directory, "weights.txt")
|
|
test:
flair/datasets/base.py#L341
ruff
pytest_ruff.RuffError: flair/datasets/base.py:232:8: E721 Do not compare types, use `isinstance()`
|
231 | def find_train_dev_test_files(data_folder, dev_file, test_file, train_file, autofind_splits=True):
232 | if type(data_folder) == str:
| ^^^^^^^^^^^^^^^^^^^^^^^^ E721
233 | data_folder: Path = Path(data_folder)
|
|
test:
flair/datasets/sequence_labeling.py#L341
ruff
pytest_ruff.RuffError: flair/datasets/sequence_labeling.py:2979:12: E721 Do not compare types, use `isinstance()`
|
2978 | # if only one language is given
2979 | if type(languages) == str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
2980 | languages = [languages]
|
flair/datasets/sequence_labeling.py:3252:12: E721 Do not compare types, use `isinstance()`
|
3250 | Specify that the dataset should be loaded in memory, which speeds up the training process but takes increases the RAM usage significantly.
3251 | """
3252 | if type(languages) == str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
3253 | languages = [languages]
|
flair/datasets/sequence_labeling.py:3713:12: E721 Do not compare types, use `isinstance()`
|
3712 | # if only one language is given
3713 | if type(languages) == str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
3714 | languages = [languages]
|
flair/datasets/sequence_labeling.py:3805:12: E721 Do not compare types, use `isinstance()`
|
3804 | # if only one language is given
3805 | if type(languages) == str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
3806 | languages = [languages]
|
flair/datasets/sequence_labeling.py:4751:12: E721 Do not compare types, use `isinstance()`
|
4749 | supported_domains = ["WN", "FIC", "ADG"]
4750 |
4751 | if type(domains) == str and domains == "all":
| ^^^^^^^^^^^^^^^^^^^^ E721
4752 | domains = supported_domains
|
flair/datasets/sequence_labeling.py:4754:12: E721 Do not compare types, use `isinstance()`
|
4752 | domains = supported_domains
4753 |
4754 | if type(domains) == str:
| ^^^^^^^^^^^^^^^^^^^^ E721
4755 | domains = [domains]
|
|
test:
flair/models/tars_model.py#L341
ruff
pytest_ruff.RuffError: flair/models/tars_model.py:198:16: E721 Do not compare types, use `isinstance()`
|
196 | if isinstance(label_dictionary, Dictionary):
197 | label_dictionary = label_dictionary.get_items()
198 | if type(label_dictionary) == str:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721
199 | label_dictionary = [label_dictionary]
|
|
test:
flair/trainers/language_model_trainer.py#L341
ruff
pytest_ruff.RuffError: flair/trainers/language_model_trainer.py:59:12: E721 Do not compare types, use `isinstance()`
|
57 | def __getitem__(self, index=0) -> torch.Tensor:
58 | """Tokenizes a text file on character basis."""
59 | if type(self.files[index]) is str:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721
60 | self.files[index] = Path(self.files[index])
61 | assert self.files[index].exists()
|
flair/trainers/language_model_trainer.py:447:12: E721 Do not compare types, use `isinstance()`
|
445 | optimizer: Type[Optimizer] = SGD,
446 | ):
447 | if type(checkpoint_file) is str:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721
448 | checkpoint_file = Path(checkpoint_file)
|
|
test:
flair/trainers/trainer.py#L341
ruff
pytest_ruff.RuffError: flair/trainers/trainer.py:142:31: PYI041 Use `float` instead of `int | float`
|
140 | main_evaluation_metric: Tuple[str, str] = ("micro avg", "f1-score"),
141 | monitor_test: bool = False,
142 | monitor_train_sample: Union[float, int] = 0.0,
| ^^^^^^^^^^^^^^^^^ PYI041
143 | use_final_model_for_eval: bool = False,
144 | gold_label_dictionary_for_eval: Optional[Dictionary] = None,
|
flair/trainers/trainer.py:214:31: PYI041 Use `float` instead of `int | float`
|
212 | main_evaluation_metric: Tuple[str, str] = ("micro avg", "f1-score"),
213 | monitor_test: bool = False,
214 | monitor_train_sample: Union[float, int] = 0.0,
| ^^^^^^^^^^^^^^^^^ PYI041
215 | use_final_model_for_eval: bool = True,
216 | gold_label_dictionary_for_eval: Optional[Dictionary] = None,
|
flair/trainers/trainer.py:305:31: PYI041 Use `float` instead of `int | float`
|
303 | main_evaluation_metric: Tuple[str, str] = ("micro avg", "f1-score"),
304 | monitor_test: bool = False,
305 | monitor_train_sample: Union[float, int] = 0.0,
| ^^^^^^^^^^^^^^^^^ PYI041
306 | use_final_model_for_eval: bool = False,
307 | gold_label_dictionary_for_eval: Optional[Dictionary] = None,
|
|
test:
flair/visual/training_curves.py#L341
ruff
pytest_ruff.RuffError: flair/visual/training_curves.py:70:12: E721 Do not compare types, use `isinstance()`
|
68 | @staticmethod
69 | def _extract_weight_data(file_name: Union[str, Path]) -> dict:
70 | if type(file_name) is str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
71 | file_name = Path(file_name)
|
flair/visual/training_curves.py:89:12: E721 Do not compare types, use `isinstance()`
|
87 | @staticmethod
88 | def _extract_learning_rate(file_name: Union[str, Path]):
89 | if type(file_name) is str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
90 | file_name = Path(file_name)
|
|
test:
tests/model_test_utils.py#L341
ruff
pytest_ruff.RuffError: tests/model_test_utils.py:207:20: E721 Do not compare types, use `isinstance()`
|
205 | assert label.value is not None
206 | assert 0.0 <= label.score <= 1.0
207 | assert type(label.score) is float
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ E721
208 |
209 | del trainer, model, multi_class_corpus
|
|