Karim shoair commited on
Commit
a2a8556
·
1 Parent(s): 8d013d4

style(utils): optimize imports

Browse files
Files changed (1) hide show
  1. scrapling/core/utils.py +6 -6
scrapling/core/utils.py CHANGED
@@ -1,11 +1,11 @@
1
  import logging
2
- import re
3
  from itertools import chain
 
4
 
5
- import orjson
6
  from lxml import html
7
 
8
- from scrapling.core._types import Any, Dict, Iterable, Union, List
9
 
10
  # Using cache on top of a class is a brilliant way to achieve a Singleton design pattern without much code
11
  from functools import lru_cache # isort:skip
@@ -15,7 +15,7 @@ html_forbidden = {
15
  }
16
 
17
  __CLEANING_TABLE__ = str.maketrans({"\t": " ", "\n": None, "\r": None})
18
- __CONSECUTIVE_SPACES_REGEX__ = re.compile(r" +")
19
 
20
 
21
  @lru_cache(1, typed=True)
@@ -49,9 +49,9 @@ def is_jsonable(content: bytes | str) -> bool:
49
  content = content.decode()
50
 
51
  try:
52
- _ = orjson.loads(content)
53
  return True
54
- except orjson.JSONDecodeError:
55
  return False
56
 
57
 
 
1
  import logging
 
2
  from itertools import chain
3
+ from re import compile as re_compile
4
 
5
+ from orjson import loads as orjson_loads, JSONDecodeError
6
  from lxml import html
7
 
8
+ from scrapling.core._types import Any, Dict, Iterable, List
9
 
10
  # Using cache on top of a class is a brilliant way to achieve a Singleton design pattern without much code
11
  from functools import lru_cache # isort:skip
 
15
  }
16
 
17
  __CLEANING_TABLE__ = str.maketrans({"\t": " ", "\n": None, "\r": None})
18
+ __CONSECUTIVE_SPACES_REGEX__ = re_compile(r" +")
19
 
20
 
21
  @lru_cache(1, typed=True)
 
49
  content = content.decode()
50
 
51
  try:
52
+ _ = orjson_loads(content)
53
  return True
54
+ except JSONDecodeError:
55
  return False
56
 
57