Skip to content

Commit

Permalink
Merge pull request #2748 from xqm32/theme-read-encoding
Browse files Browse the repository at this point in the history
Added `encoding` parameter in `Theme.read`
  • Loading branch information
willmcgugan committed Jan 27, 2023
2 parents b2f9987 + 0e53bae commit 9a19862
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Added `encoding` parameter in `Theme.read`


## [13.2.0] - 2023-01-19

### Changed
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ The following people have contributed to the development of Rich:
- [Serkan UYSAL](https://github.com/uysalserkan)
- [Zhe Huang](https://github.com/onlyacat)
- [Ke Sun](https://github.com/ksun212)
- [Qiming Xu](https://github.com/xqm32)
7 changes: 5 additions & 2 deletions rich/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ def from_file(
return theme

@classmethod
def read(cls, path: str, inherit: bool = True) -> "Theme":
def read(
cls, path: str, inherit: bool = True, encoding: Optional[str] = None
) -> "Theme":
"""Read a theme from a path.
Args:
path (str): Path to a config file readable by Python configparser module.
inherit (bool, optional): Inherit default styles. Defaults to True.
encoding (str, optional): Encoding of the config file. Defaults to None.
Returns:
Theme: A new theme instance.
"""
with open(path, "rt") as config_file:
with open(path, "rt", encoding=encoding) as config_file:
return cls.from_file(config_file, source=path, inherit=inherit)


Expand Down

0 comments on commit 9a19862

Please sign in to comment.