Skip to content

Commit 03a5213

Browse files
authored
Merge pull request #116 from willmcgugan/dev
Local development environment improvements
2 parents fb1a69c + f1c335f commit 03a5213

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+160
-129
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
runs-on: ubuntu-latest
7+
runs-on: ${{ matrix.os }}
88
strategy:
99
max-parallel: 4
1010
matrix:
11+
os: [ubuntu-latest, windows-latest, macos-latest]
1112
python-version: [3.6, 3.7, 3.8]
1213

1314
steps:
@@ -19,14 +20,12 @@ jobs:
1920
- name: Install dependencies
2021
run: |
2122
python -m pip install --upgrade pip
22-
pip install -r requirements.txt
23+
pip install -r requirements-dev.txt
24+
poetry install
2325
- name: Typecheck with mypy
2426
run: |
25-
pip install mypy==0.770
2627
make typecheck
2728
- name: Test with pytest
2829
run: |
29-
pip install poetry pytest
30-
poetry install
3130
pip install .
3231
pytest tests/ -v

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.2.4] - 2020-06-21
9+
10+
### Added
11+
12+
- Added enable_link_path to RichHandler
13+
- Added legacy_windows switch to Console contstructor
14+
815
## [2.2.3] - 2020-06-15
916

1017
### Fixed

CONTRIBUTING.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Contributing to Rich
2+
3+
This project welcomes contributions in the form of Pull Requests. For clear bug-fixes / typos etc. just submit a PR. For new features or if there is any doubt in how to fix a bug, you might want to open an issue prior to starting work, or email willmcgugan+rich@gmail.com to discuss it first.
4+
5+
## Development Environment
6+
7+
To start developing with Rich, first create a _virtual environment_ then run the following to install development requirements:
8+
9+
```
10+
pip install -r requirements-dev.txt
11+
poetry install
12+
```
13+
14+
### Tests
15+
16+
Run tests with the following command:
17+
18+
```
19+
make test
20+
```
21+
22+
Or if you don't have make, run the following:
23+
24+
```
25+
pytest --cov-report term-missing --cov=rich tests/ -vv
26+
```
27+
28+
New code should ideally have tests and not break existing tests.
29+
30+
### Type Checking
31+
32+
Rich uses type annotations throughout, and `mypy` to do the checking. Run the following to type check Rich:
33+
34+
```
35+
make typecheck
36+
```
37+
38+
Or if you don't have `make`:
39+
40+
```
41+
mypy -p rich --ignore-missing-imports --warn-unreachable
42+
```
43+
44+
Please add type annotations for all new code.
45+
46+
### Code Formatting
47+
48+
Rich uses `black` for code formatting. I recommend setting up black in your editor to format on save.

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ typecheck:
44
mypy -p rich --ignore-missing-imports --warn-unreachable
55
typecheck-report:
66
mypy -p rich --ignore-missing-imports --warn-unreachable --html-report mypy_report
7-
pytype:
8-
pytype --config=pytype.cfg
97
.PHONY: docs
108
docs:
119
cd docs; make html

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[![PyPI version](https://badge.fury.io/py/rich.svg)](https://badge.fury.io/py/rich)
22
[![PyPI](https://img.shields.io/pypi/pyversions/rich.svg)](https://pypi.org/project/rich/)
3-
[![Downloads](https://pepy.tech/badge/rich/month)](https://pepy.tech/project/rich/month)
4-
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://awesome-python.com/#command-line-interface-development)
5-
63
[![Rich blog](https://img.shields.io/badge/blog-rich%20news-yellowgreen)](https://www.willmcgugan.com/tag/rich/)
74
[![Twitter Follow](https://img.shields.io/twitter/follow/willmcgugan.svg?style=social)](https://twitter.com/willmcgugan)
85

poetry.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rich"
33
homepage = "https://github.com/willmcgugan/rich"
44
documentation = "https://rich.readthedocs.io/en/latest/"
5-
version = "2.2.3"
5+
version = "2.2.4"
66
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
77
authors = ["Will McGugan <willmcgugan@gmail.com>"]
88
license = "MIT"

requirements-dev.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
black==19.10b0
2+
mypy==0.781
3+
poetry==1.0.5
4+
pytest==5.4.3

requirements.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

rich/_log_render.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import Any, Iterable, List, Optional, TYPE_CHECKING, Union
2+
from typing import Iterable, List, Optional, TYPE_CHECKING, Union
33

44

55
from .text import Text

rich/_lru_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections import OrderedDict
2-
from typing import Dict, Generic, Mapping, TypeVar
2+
from typing import Dict, Generic, TypeVar
33

44

55
CacheKey = TypeVar("CacheKey")

rich/_ratio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from dataclasses import dataclass
21
from math import ceil
32
from typing import List
43

rich/align.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
from typing_extensions import Literal
44
from .jupyter import JupyterMixin
5-
from .measure import Measurement
65
from .segment import Segment
7-
from .style import StyleType
6+
87

98
if TYPE_CHECKING:
109
from .console import Console, ConsoleOptions, RenderResult, RenderableType

rich/bar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from functools import lru_cache
22
import math
33
from time import monotonic
4-
from typing import Iterable, Optional, List, Union
4+
from typing import Iterable, Optional, List
55

66
from .color import Color, blend_rgb
77
from .color_triplet import ColorTriplet

rich/cells.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from functools import lru_cache
2-
from itertools import takewhile
3-
from typing import Dict, List, Tuple
2+
from typing import Dict, List
43

54
from ._cell_widths import CELL_WIDTHS
65
from ._lru_cache import LRUCache

rich/color.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import re
22
from colorsys import rgb_to_hls
3-
from dataclasses import dataclass
43
from enum import IntEnum
54
from functools import lru_cache
6-
from math import sqrt
75
import platform
8-
from typing import Iterable, List, NamedTuple, Optional, Sequence, Tuple, TYPE_CHECKING
6+
from typing import NamedTuple, Optional, Tuple, TYPE_CHECKING
97

108
from ._palettes import STANDARD_PALETTE, EIGHT_BIT_PALETTE
119
from .color_triplet import ColorTriplet

rich/columns.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from .measure import Measurement
99
from .padding import Padding, PaddingDimensions
1010
from .table import Table
11-
from .text import Text
1211
from .jupyter import JupyterMixin
1312

1413

rich/console.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from collections.abc import Mapping, Sequence
2-
from contextlib import contextmanager
2+
33
from dataclasses import dataclass, field, replace
4-
from enum import Enum
4+
55
from functools import wraps
66
import inspect
7-
from itertools import chain
7+
88
import os
9-
from operator import itemgetter
9+
1010
import platform
11-
import re
11+
1212
import shutil
1313
import sys
1414
import threading
@@ -22,38 +22,28 @@
2222
List,
2323
Optional,
2424
NamedTuple,
25-
overload,
26-
Tuple,
27-
TYPE_CHECKING,
2825
Union,
2926
)
3027
from typing_extensions import Protocol, runtime_checkable, Literal
3128

32-
3329
from ._emoji_replace import _emoji_replace
34-
3530
from .align import Align, AlignValues
3631
from .markup import render as render_markup
3732
from .measure import measure_renderables, Measurement
3833
from ._log_render import LogRender
39-
from .default_styles import DEFAULT_STYLES
4034
from . import errors
4135
from .color import ColorSystem
4236
from .control import Control
4337
from .highlighter import NullHighlighter, ReprHighlighter
4438
from .pretty import Pretty
4539
from .style import Style
4640
from .tabulate import tabulate_mapping
47-
from . import highlighter
4841
from . import themes
49-
from .pretty import Pretty
5042
from .terminal_theme import TerminalTheme, DEFAULT_TERMINAL_THEME
5143
from .segment import Segment
5244
from .text import Text
5345
from .theme import Theme
5446

55-
if TYPE_CHECKING: # pragma: no cover
56-
from .text import Text
5747

5848
WINDOWS = platform.system() == "Windows"
5949

@@ -151,10 +141,10 @@ def __rich_console__(
151141

152142
class RenderGroup:
153143
"""Takes a group of renderables and returns a renderable object that renders the group.
154-
144+
155145
Args:
156146
renderables (Iterable[RenderableType]): An iterable of renderable objects.
157-
147+
158148
"""
159149

160150
def __init__(self, *renderables: RenderableType, fit: bool = True) -> None:
@@ -285,7 +275,8 @@ class Console:
285275
log_time (bool, optional): Boolean to enable logging of time by :meth:`log` methods. Defaults to True.
286276
log_path (bool, optional): Boolean to enable the logging of the caller by :meth:`log`. Defaults to True.
287277
log_time_format (str, optional): Log time format if ``log_time`` is enabled. Defaults to "[%X] ".
288-
highlighter(HighlighterType, optional): Default highlighter.
278+
highlighter (HighlighterType, optional): Default highlighter.
279+
legacy_windows (bool, optional): Enable legacy Windows mode, or ``None`` to auto detect. Defaults to ``None``.
289280
"""
290281

291282
def __init__(
@@ -309,6 +300,7 @@ def __init__(
309300
log_path: bool = True,
310301
log_time_format: str = "[%X]",
311302
highlighter: Optional["HighlighterType"] = ReprHighlighter(),
303+
legacy_windows: bool = None,
312304
):
313305
self.is_jupyter = force_jupyter or _is_jupyter()
314306
if self.is_jupyter:
@@ -322,7 +314,9 @@ def __init__(
322314
self._markup = markup
323315
self._emoji = emoji
324316
self._highlight = highlight
325-
self.legacy_windows: bool = detect_legacy_windows()
317+
self.legacy_windows: bool = (
318+
detect_legacy_windows() if legacy_windows is None else legacy_windows
319+
)
326320

327321
self._color_system: Optional[ColorSystem]
328322
self._force_terminal = force_terminal

rich/containers.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@
33
Iterator,
44
Iterable,
55
List,
6-
Optional,
76
overload,
87
TypeVar,
98
TYPE_CHECKING,
10-
Union,
119
)
12-
from typing_extensions import Literal
1310

14-
from .segment import Segment
1511
from .style import Style
1612

1713
if TYPE_CHECKING:
1814
from .console import (
1915
Console,
2016
ConsoleOptions,
21-
ConsoleRenderable,
2217
JustifyMethod,
2318
OverflowMethod,
2419
RenderResult,

rich/control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import NamedTuple, TYPE_CHECKING
1+
from typing import TYPE_CHECKING
22

33
from .segment import Segment
44

rich/emoji.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import re
21
from typing import Match, Union
32

4-
from .console import Console, ConsoleOptions, ConsoleRenderable, RenderResult
3+
from .console import Console, ConsoleOptions, RenderResult
54
from .jupyter import JupyterMixin
65
from .segment import Segment
76
from .style import Style

rich/filesize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
"""
1313

14-
__all__ = ["traditional", "decimal", "binary"]
14+
__all__ = ["decimal"]
1515

1616
from typing import Iterable, List, Tuple
1717

rich/highlighter.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from abc import ABC, abstractmethod
2-
from re import finditer
32
from typing import List, Union
43

5-
64
from .text import Text
75

86

rich/jupyter.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import io
2-
from typing import Any, Iterable, IO, List, Optional, TYPE_CHECKING, Union
1+
from typing import Iterable, List, TYPE_CHECKING
32

43
# from .console import Console as BaseConsole
54
from .__init__ import get_console
65
from .segment import Segment
7-
from .style import Style
86
from .terminal_theme import DEFAULT_TERMINAL_THEME
97

108
if TYPE_CHECKING:
11-
from .console import Console, RenderableType
9+
from .console import RenderableType
1210

1311
JUPYTER_HTML_FORMAT = """\
1412
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">{code}</pre>

0 commit comments

Comments
 (0)