Skip to content

Commit 64d0475

Browse files
authored
❇️ Add unicode version output in CLI --version (#194)
And deprecate the use of unicodedata2
1 parent af9f36f commit 64d0475

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
44

55
## [2.1.0.dev0](https://github.com/Ousret/charset_normalizer/compare/2.0.12...master) (2022-??-??)
66

7+
### Added
8+
- Output the Unicode table version when running the CLI with `--version` (PR #194)
9+
710
### Changed
811
- Re-use decoded buffer for single byte character sets from [@nijel](https://github.com/nijel) (PR #175)
912
- Fixing some performance bottlenecks from [@deedy5](https://github.com/deedy5) (PR #183)
@@ -15,6 +18,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1518
### Removed
1619
- Support for Python 3.5 (PR #192)
1720

21+
### Deprecated
22+
- Use of backport unicodedata from `unicodedata2` as Python is quickly catching up, scheduled for removal in 3.0 (PR #194)
23+
1824
## [2.0.12](https://github.com/Ousret/charset_normalizer/compare/2.0.11...2.0.12) (2022-02-12)
1925

2026
### Fixed

charset_normalizer/cli/normalizer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
from platform import python_version
66
from typing import List
77

8+
try:
9+
from unicodedata2 import unidata_version
10+
except ImportError:
11+
from unicodedata import unidata_version
12+
813
from charset_normalizer import from_fp
914
from charset_normalizer.models import CliDetectionResult
1015
from charset_normalizer.version import __version__
@@ -119,8 +124,8 @@ def cli_detect(argv: List[str] = None) -> int:
119124
parser.add_argument(
120125
"--version",
121126
action="version",
122-
version="Charset-Normalizer {} - Python {}".format(
123-
__version__, python_version()
127+
version="Charset-Normalizer {} - Python {} - Unicode {}".format(
128+
__version__, python_version(), unidata_version
124129
),
125130
help="Show version information and exit.",
126131
)

charset_normalizer/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
try:
2+
# WARNING: unicodedata2 support is going to be removed in 3.0
3+
# Python is quickly catching up.
24
import unicodedata2 as unicodedata
35
except ImportError:
46
import unicodedata # type: ignore[no-redef]

0 commit comments

Comments
 (0)