Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan authored Jul 29, 2023
2 parents d9eff2a + 0c8bb03 commit 80e66aa
Show file tree
Hide file tree
Showing 15 changed files with 304 additions and 53 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "CodeQL"

on:
push:
branches: [ 'master' ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ 'master' ]
schedule:
- cron: '38 19 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ repos:
hooks:
- id: black
exclude: ^benchmarks/
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
exclude: ^benchmarks/
name: isort (python)
language_version: '3.11'
args: ["--profile", "black"]
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,28 @@ 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).

## [13.4.3] - 2023-06-22

## Unreleased

### Fixed

- Fixed Text.expand_tabs not expanding spans.
- Fixed TimeElapsedColumn from showing negative.
- Fix for escaping strings with a trailing backslash https://github.com/Textualize/rich/issues/2987
- Fixed exception in Markdown with partial table https://github.com/Textualize/rich/issues/3053
- Fixed the HTML export template so that the `<html>` tag comes before the `<head>` tag https://github.com/Textualize/rich/issues/3021
- Fixed issue with custom classes overwriting `__eq__` https://github.com/Textualize/rich/issues/2875

### Added

- Added Text.extend_style method.
- Added Span.extend method.

### Changed

- Text.tab_size now defaults to `None` to indicate that Console.tab_size should be used.


## [13.4.2] - 2023-06-12

### Changed
Expand Down Expand Up @@ -82,7 +98,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed failing tests due to Pygments dependency https://github.com/Textualize/rich/issues/2757
- Relaxed ipywidgets https://github.com/Textualize/rich/issues/2767

### Added
### Added

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

Expand Down
2 changes: 1 addition & 1 deletion docs/source/markup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Escaping is important if you construct console markup dynamically, with ``str.fo
def greet(name):
console.print(f"Hello {name}!")

Calling ``greet("Will")`` will print a greeting, but if you were to call ``greet("[blink]Gotcha![/blink]"])`` then you will also get blinking text, which may not be desirable. The solution is to escape the arguments::
Calling ``greet("Will")`` will print a greeting, but if you were to call ``greet("[blink]Gotcha![/blink]")`` then you will also get blinking text, which may not be desirable. The solution is to escape the arguments::

from rich.markup import escape
def greet(name):
Expand Down
2 changes: 1 addition & 1 deletion rich/_export_format.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CONSOLE_HTML_FORMAT = """\
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
Expand All @@ -10,7 +11,6 @@
}}
</style>
</head>
<html>
<body>
<pre style="font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code>{code}</code></pre>
</body>
Expand Down
1 change: 0 additions & 1 deletion rich/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,6 @@ def log(
end (str, optional): String to write at end of print data. Defaults to "\\\\n".
style (Union[str, Style], optional): A style to apply to output. Defaults to None.
justify (str, optional): One of "left", "right", "center", or "full". Defaults to ``None``.
overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None.
emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. Defaults to None.
markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. Defaults to None.
highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to None.
Expand Down
17 changes: 8 additions & 9 deletions rich/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,14 @@ def __rich_console__(
) -> RenderResult:
table = Table(box=box.SIMPLE_HEAVY)

assert self.header is not None
assert self.header.row is not None
for column in self.header.row.cells:
table.add_column(column.content)

assert self.body is not None
for row in self.body.rows:
row_content = [element.content for element in row.cells]
table.add_row(*row_content)
if self.header is not None and self.header.row is not None:
for column in self.header.row.cells:
table.add_column(column.content)

if self.body is not None:
for row in self.body.rows:
row_content = [element.content for element in row.cells]
table.add_row(*row_content)

yield table

Expand Down
4 changes: 3 additions & 1 deletion rich/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def escape_backslashes(match: Match[str]) -> str:
return f"{backslashes}{backslashes}\\{text}"

markup = _escape(escape_backslashes, markup)
if markup.endswith("\\") and not markup.endswith("\\\\"):
return markup + "\\"

return markup


Expand Down Expand Up @@ -226,7 +229,6 @@ def pop_style(style_name: str) -> Tuple[int, Tag]:


if __name__ == "__main__": # pragma: no cover

MARKUP = [
"[red]Hello World[/red]",
"[magenta]Hello [b]World[/b]",
Expand Down
5 changes: 1 addition & 4 deletions rich/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def render(self, task: "Task") -> Text:
elapsed = task.finished_time if task.finished else task.elapsed
if elapsed is None:
return Text("-:--:--", style="progress.elapsed")
delta = timedelta(seconds=int(elapsed))
delta = timedelta(seconds=max(0, int(elapsed)))
return Text(str(delta), style="progress.elapsed")


Expand Down Expand Up @@ -710,7 +710,6 @@ def __init__(
table_column: Optional[Column] = None,
show_speed: bool = False,
) -> None:

self.text_format_no_percentage = text_format_no_percentage
self.show_speed = show_speed
super().__init__(
Expand Down Expand Up @@ -1636,7 +1635,6 @@ def remove_task(self, task_id: TaskID) -> None:


if __name__ == "__main__": # pragma: no coverage

import random
import time

Expand Down Expand Up @@ -1689,7 +1687,6 @@ def remove_task(self, task_id: TaskID) -> None:
console=console,
transient=False,
) as progress:

task1 = progress.add_task("[red]Downloading", total=1000)
task2 = progress.add_task("[green]Processing", total=1000)
task3 = progress.add_task("[yellow]Thinking", total=None)
Expand Down
Loading

0 comments on commit 80e66aa

Please sign in to comment.