Merge pull request #3240 from flairNLP/variable_grad_norm_clipping #1935
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#L341
ruff
pytest_ruff.RuffError: flair/tokenization.py:259:17: UP032 [*] Use f-string instead of `format` call
|
257 | r"(?<=[0-9])[+\-\*^](?=[0-9-])",
258 | rf"(?<=[{char_classes.ALPHA_LOWER}])\.(?=[{char_classes.ALPHA_UPPER}])",
259 | r"(?<=[{a}]),(?=[{a}])".format(a=char_classes.ALPHA),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032
260 | r'(?<=[{a}])[?";:=,.]*(?:{h})(?=[{a}])'.format(a=char_classes.ALPHA, h=char_classes.HYPHENS),
261 | r"(?<=[{a}0-9])[:<>=/](?=[{a}])".format(a=char_classes.ALPHA),
|
= help: Convert to f-string
flair/tokenization.py:260:17: UP032 [*] Use f-string instead of `format` call
|
258 | rf"(?<=[{char_classes.ALPHA_LOWER}])\.(?=[{char_classes.ALPHA_UPPER}])",
259 | r"(?<=[{a}]),(?=[{a}])".format(a=char_classes.ALPHA),
260 | r'(?<=[{a}])[?";:=,.]*(?:{h})(?=[{a}])'.format(a=char_classes.ALPHA, h=char_classes.HYPHENS),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032
261 | r"(?<=[{a}0-9])[:<>=/](?=[{a}])".format(a=char_classes.ALPHA),
262 | ]
|
= help: Convert to f-string
flair/tokenization.py:261:17: UP032 [*] Use f-string instead of `format` call
|
259 | r"(?<=[{a}]),(?=[{a}])".format(a=char_classes.ALPHA),
260 | r'(?<=[{a}])[?";:=,.]*(?:{h})(?=[{a}])'.format(a=char_classes.ALPHA, h=char_classes.HYPHENS),
261 | r"(?<=[{a}0-9])[:<>=/](?=[{a}])".format(a=char_classes.ALPHA),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032
262 | ]
263 | )
|
= help: Convert to f-string
|
test:
flair/training_utils.py#L341
ruff
pytest_ruff.RuffError: flair/training_utils.py:74:20: UP032 [*] Use f-string instead of `format` call
|
72 | def tsv_header(prefix=None):
73 | if prefix:
74 | return "{0}_MEAN_SQUARED_ERROR\t{0}_MEAN_ABSOLUTE_ERROR\t{0}_PEARSON\t{0}_SPEARMAN".format(prefix)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032
75 |
76 | return "MEAN_SQUARED_ERROR\tMEAN_ABSOLUTE_ERROR\tPEARSON\tSPEARMAN"
|
= help: Convert to f-string
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:2976:12: E721 Do not compare types, use `isinstance()`
|
2975 | # if only one language is given
2976 | if type(languages) == str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
2977 | languages = [languages]
|
flair/datasets/sequence_labeling.py:3249:12: E721 Do not compare types, use `isinstance()`
|
3247 | Specify that the dataset should be loaded in memory, which speeds up the training process but takes increases the RAM usage significantly.
3248 | """
3249 | if type(languages) == str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
3250 | languages = [languages]
|
flair/datasets/sequence_labeling.py:3710:12: E721 Do not compare types, use `isinstance()`
|
3709 | # if only one language is given
3710 | if type(languages) == str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
3711 | languages = [languages]
|
flair/datasets/sequence_labeling.py:3802:12: E721 Do not compare types, use `isinstance()`
|
3801 | # if only one language is given
3802 | if type(languages) == str:
| ^^^^^^^^^^^^^^^^^^^^^^ E721
3803 | languages = [languages]
|
flair/datasets/sequence_labeling.py:4748:12: E721 Do not compare types, use `isinstance()`
|
4746 | supported_domains = ["WN", "FIC", "ADG"]
4747 |
4748 | if type(domains) == str and domains == "all":
| ^^^^^^^^^^^^^^^^^^^^ E721
4749 | domains = supported_domains
|
flair/datasets/sequence_labeling.py:4751:12: E721 Do not compare types, use `isinstance()`
|
4749 | domains = supported_domains
4750 |
4751 | if type(domains) == str:
| ^^^^^^^^^^^^^^^^^^^^ E721
4752 | 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
|
|