mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-11 17:14:41 +00:00
all: ruff check --fix.
Mainly fixes and sorts imports.
This commit is contained in:
@@ -11,7 +11,7 @@ return types. This extension:
|
||||
call these functions.
|
||||
"""
|
||||
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
from docutils import nodes
|
||||
from sphinx.addnodes import desc_sig_keyword
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from docutils.parsers.rst import Directive
|
||||
from docutils import nodes
|
||||
from pathlib import Path
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive
|
||||
|
||||
SPHINX_IMAGE_PATH = "blockimg"
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class PybricksClasslinkDirective(Directive):
|
||||
link = name if len(self.arguments) == 1 else self.arguments[1]
|
||||
|
||||
html = (
|
||||
'<a href="{0}.html">'.format(link.lower())
|
||||
f'<a href="{link.lower()}.html">'
|
||||
+ '<dl class="py class">'
|
||||
+ "<dt>"
|
||||
+ '<em class="property">class </em>'
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from colorsys import hsv_to_rgb
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive
|
||||
|
||||
from pybricks.parameters import Color
|
||||
from colorsys import hsv_to_rgb
|
||||
|
||||
|
||||
class PybricksColorDirective(Directive):
|
||||
@@ -18,19 +20,17 @@ class PybricksColorDirective(Directive):
|
||||
r, g, b = hsv_to_rgb(color.h / 360, color.s / 100, color.v / 100)
|
||||
|
||||
# Convert RGB to HEX
|
||||
rgbhex = "#{0:02x}{1:02x}{2:02x}".format(
|
||||
round(r * 255), round(g * 255), round(b * 255)
|
||||
)
|
||||
rgbhex = f"#{round(r * 255):02x}{round(g * 255):02x}{round(b * 255):02x}"
|
||||
|
||||
# Render a small block of the given color
|
||||
css = "background-color: {0}; color: {0}; width: 50px;".format(rgbhex)
|
||||
css = f"background-color: {rgbhex}; color: {rgbhex}; width: 50px;"
|
||||
|
||||
if name == "WHITE":
|
||||
css += (
|
||||
"border-style: solid; border-width: 0.5px;" + "border-color: #666666;"
|
||||
)
|
||||
|
||||
html = '<div id="test" style="{0}">_</div>'.format(css)
|
||||
html = f'<div id="test" style="{css}">_</div>'
|
||||
|
||||
# Return the node
|
||||
node = nodes.raw("", html, format="html")
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from os import path, makedirs
|
||||
from os import makedirs, path
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive
|
||||
|
||||
from sphinx.util.osutil import copyfile
|
||||
|
||||
# Base feature set.
|
||||
@@ -72,7 +71,7 @@ class PybricksRequirementsStaticDirective(Directive):
|
||||
makedirs(destdir)
|
||||
|
||||
for hub in HUB_FEATURES:
|
||||
uri = "compat_{0}.png".format(hub)
|
||||
uri = f"compat_{hub}.png"
|
||||
src_uri = path.join(env.app.builder.srcdir, "diagrams", uri)
|
||||
build_uri = path.join(env.app.builder.outdir, "_images", uri)
|
||||
copyfile(src_uri, build_uri)
|
||||
@@ -103,17 +102,17 @@ class PybricksRequirementsStaticDirective(Directive):
|
||||
)
|
||||
|
||||
# Generate full table.
|
||||
html = """
|
||||
html = f"""
|
||||
<div class="wy-table-responsive">
|
||||
<table class="docutils align-default requirements-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
{0}
|
||||
{compat_row}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
""".format(compat_row)
|
||||
"""
|
||||
|
||||
# Return the node.
|
||||
node = nodes.raw("", html, format="html")
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
|
||||
|
||||
import os
|
||||
from docutils.parsers.rst import Directive, directives
|
||||
from docutils import nodes
|
||||
from docutils.statemachine import StringList
|
||||
from sphinx.util.osutil import copyfile
|
||||
from sphinx.util import logging
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive, directives
|
||||
from docutils.statemachine import StringList
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.osutil import copyfile
|
||||
|
||||
CSS_FILE = "requirements.css"
|
||||
JS_FILE = "requirements.js"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Pybricks documentation build configuration file
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user