Skip to content

Commit

Permalink
Fix deprecation of errors in TextConfig (#6095)
Browse files Browse the repository at this point in the history
* Fix deprecation of errors in TextConfig

* Fix typo in warning message
  • Loading branch information
albertvillanova committed Jul 31, 2023
1 parent c30ff1d commit c69e980
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/datasets/packaged_modules/text/text.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import itertools
import warnings
from dataclasses import dataclass
from dataclasses import InitVar, dataclass
from io import StringIO
from typing import Optional

Expand All @@ -20,20 +20,20 @@ class TextConfig(datasets.BuilderConfig):

features: Optional[datasets.Features] = None
encoding: str = "utf-8"
errors = "deprecated"
errors: InitVar[Optional[str]] = "deprecated"
encoding_errors: Optional[str] = None
chunksize: int = 10 << 20 # 10MB
keep_linebreaks: bool = False
sample_by: str = "line"

def __post_init__(self):
if self.errors != "deprecated":
def __post_init__(self, errors):
if errors != "deprecated":
warnings.warn(
"'errors' was deprecated in favor of 'encoding_erros' in version 2.14.0 and will be removed in 3.0.0.\n"
f"You can remove this warning by passing 'encoding_errors={self.errors}' instead.",
"'errors' was deprecated in favor of 'encoding_errors' in version 2.14.0 and will be removed in 3.0.0.\n"
f"You can remove this warning by passing 'encoding_errors={errors}' instead.",
FutureWarning,
)
self.encoding_errors = self.errors
self.encoding_errors = errors


class Text(datasets.ArrowBasedBuilder):
Expand Down

0 comments on commit c69e980

Please sign in to comment.