Mike Gabriel commited on
Commit
1a67cab
·
1 Parent(s): 002443a

Add extra typing to make pyright shut up

Browse files
Files changed (2) hide show
  1. .gitignore +2 -1
  2. dataset.py +7 -5
.gitignore CHANGED
@@ -2,4 +2,5 @@
2
  __pycache__
3
  .git
4
  .wolf*
5
- .env
 
 
2
  __pycache__
3
  .git
4
  .wolf*
5
+ .env
6
+ pyrightconfig.json
dataset.py CHANGED
@@ -1,7 +1,9 @@
1
- from typing import Literal
2
- from datasets import load_dataset, Dataset
3
 
4
- _datasets = {
 
 
5
  'train': None,
6
  'validation': None,
7
  'test': None,
@@ -12,8 +14,8 @@ _datasets = {
12
 
13
  def make_dataset(split: Literal['train', 'validation', 'test'] = 'train'):
14
  if _datasets[split] is None:
15
- ds: Dataset = load_dataset(
16
  "karpathy/tiny_shakespeare", split=split, trust_remote_code=True)
17
  out = str(list(ds)[0]['text'])
18
  _datasets[split] = out
19
- return _datasets[split]
 
1
+ from typing import Literal, Union
2
+ from datasets import load_dataset, DatasetDict
3
 
4
+ DatasetType = Union[None, str]
5
+
6
+ _datasets: dict[str, DatasetType] = {
7
  'train': None,
8
  'validation': None,
9
  'test': None,
 
14
 
15
  def make_dataset(split: Literal['train', 'validation', 'test'] = 'train'):
16
  if _datasets[split] is None:
17
+ ds = load_dataset(
18
  "karpathy/tiny_shakespeare", split=split, trust_remote_code=True)
19
  out = str(list(ds)[0]['text'])
20
  _datasets[split] = out
21
+ return str(_datasets[split])