Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from flake8 + isort + pylint to ruff #550

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply Ruff fixes
  • Loading branch information
akx committed Nov 21, 2023
commit 3cd7b4927f18e1b079fd6c9c3836def37d996805
2 changes: 1 addition & 1 deletion demo/moulinrouge.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
handler.setLevel(logging.DEBUG)
app.logger.setLevel(logging.DEBUG)
logging.getLogger('werkzeug').setLevel(logging.DEBUG)
except:
except Exception:
pass

try:
Expand Down
19 changes: 10 additions & 9 deletions demo/moulinrouge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.
from flask import Flask, render_template, Response, request
import pickle
import random
import string
from base64 import urlsafe_b64decode as b64decode
from base64 import urlsafe_b64encode as b64encode

from flask import Flask, Response, render_template, request

import pygal
from pygal.config import Config
from pygal.util import cut
from pygal.etree import etree
from pygal.style import styles, parametric_styles
from base64 import (
urlsafe_b64encode as b64encode, urlsafe_b64decode as b64decode
)
import string
import random
import pickle
from pygal.style import parametric_styles, styles
from pygal.util import cut


def get(type):
Expand Down
33 changes: 26 additions & 7 deletions demo/moulinrouge/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,30 @@
from random import choice, randint

from flask import abort

from pygal import (
CHARTS_BY_NAME, XY, Bar, Box, Config, DateLine, DateTimeLine, Dot, Funnel,
Gauge, Histogram, HorizontalBar, Line, Pie, Pyramid, Radar, SolidGauge,
StackedBar, StackedLine, TimeLine, Treemap, formatters, stats
CHARTS_BY_NAME,
XY,
Bar,
Box,
Config,
DateLine,
DateTimeLine,
Dot,
Funnel,
Gauge,
Histogram,
Line,
Pie,
Pyramid,
Radar,
SolidGauge,
StackedBar,
StackedLine,
TimeLine,
Treemap,
formatters,
stats,
)
from pygal.colors import rotate
from pygal.graph.horizontal import HorizontalGraph
Expand Down Expand Up @@ -706,7 +726,7 @@ def test_swissmap():
smap.add(
'links', [{
'value': ('kt-vs', 10),
'label': '\o/',
'label': r'\o/',
'xlink': 'http://google.com?q=69'
}, {
'value': ('bt', 20),
Expand All @@ -731,7 +751,7 @@ def test_frenchmapregions():
fmap.add(
'links', [{
'value': ('02', 10),
'label': '\o/',
'label': r'\o/',
'xlink': 'http://google.com?q=69'
}, {
'value': ('72', 20),
Expand Down Expand Up @@ -1029,7 +1049,7 @@ def test_rotations_for(chart):
@app.route('/test/datetimeline')
def test_datetimeline():
line = DateTimeLine()
from datetime import timezone, timedelta
from datetime import timedelta, timezone
tz7 = timezone(timedelta(hours=7), 'GMT +7')
tzn4 = timezone(timedelta(hours=-4), 'GMT -4')

Expand Down Expand Up @@ -1069,7 +1089,6 @@ def test_order_min():

@app.route('/test/custom_css_file')
def test_custom_css_file():
from tempfile import NamedTemporaryFile
custom_css = '''
{{ id }}text {
fill: green;
Expand Down
5 changes: 3 additions & 2 deletions docs/ext/pygal_sphinx_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
from traceback import format_exc, print_exc

import docutils.core
import pygal
from docutils.parsers.rst import Directive
from sphinx.directives.code import CodeBlock

import pygal

# Patch default style

pygal.config.Config.style.value = pygal.style.RotateStyle(
Expand Down Expand Up @@ -76,7 +77,7 @@ def run(self):
)
]
if self.render_fix:
rv = scope['rv']
_rv = scope['rv']
else:
chart = None
for key, value in scope.items():
Expand Down
3 changes: 2 additions & 1 deletion perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def cht(s):

if '--mem' in sys.argv:
_TWO_20 = float(2 ** 20)
import linecache
import os

import psutil
import linecache
pid = os.getpid()
process = psutil.Process(pid)
import gc
Expand Down
4 changes: 2 additions & 2 deletions pygal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def __repr__(self):
This is a hack to generate doc from inner doc
"""
return """
Type: %s%s     
Default: %r     
Type: %s%s
Default: %r
%s%s
""" % (
self.type.__name__, (' of %s' % self.subtype.__name__)
Expand Down
14 changes: 12 additions & 2 deletions pygal/graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@
from pygal.graph.public import PublicApi
from pygal.interpolate import INTERPOLATIONS
from pygal.util import (
cached_property, compute_scale, cut, decorate, filter_kwargs, get_text_box,
get_texts_box, majorize, rad, reverse_text_len, split_title, truncate
cached_property,
compute_scale,
cut,
decorate,
filter_kwargs,
get_text_box,
get_texts_box,
majorize,
rad,
reverse_text_len,
split_title,
truncate,
)
from pygal.view import LogView, ReverseView, View, XYLogView

Expand Down
9 changes: 7 additions & 2 deletions pygal/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@
from pygal._compat import to_str, u
from pygal.etree import etree
from pygal.util import (
coord_abs_project, coord_diff, coord_dual, coord_format, coord_project,
minify_css, template
coord_abs_project,
coord_diff,
coord_dual,
coord_format,
coord_project,
minify_css,
template,
)

nearly_2pi = 2 * pi - .00001
Expand Down
11 changes: 9 additions & 2 deletions pygal/test/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@
from __future__ import division

from pygal.colors import (
darken, desaturate, hsl_to_rgb, lighten, parse_color, rgb_to_hsl, rotate,
saturate, unparse_color
darken,
desaturate,
hsl_to_rgb,
lighten,
parse_color,
rgb_to_hsl,
rotate,
saturate,
unparse_color,
)


Expand Down
27 changes: 23 additions & 4 deletions pygal/test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,29 @@
from tempfile import NamedTemporaryFile

from pygal import (
XY, Bar, Box, Config, DateLine, DateTimeLine, Dot, Funnel, Gauge,
Histogram, HorizontalBar, HorizontalLine, HorizontalStackedBar,
HorizontalStackedLine, Line, Pie, Pyramid, Radar, SolidGauge,
TimeDeltaLine, TimeLine, Treemap, formatters
XY,
Bar,
Box,
Config,
DateLine,
DateTimeLine,
Dot,
Funnel,
Gauge,
Histogram,
HorizontalBar,
HorizontalLine,
HorizontalStackedBar,
HorizontalStackedLine,
Line,
Pie,
Pyramid,
Radar,
SolidGauge,
TimeDeltaLine,
TimeLine,
Treemap,
formatters,
)
from pygal._compat import _ellipsis, u
from pygal.graph.dual import Dual
Expand Down
8 changes: 6 additions & 2 deletions pygal/test/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@

from pygal import Line
from pygal.style import (
DarkenStyle, DesaturateStyle, LightenStyle, LightStyle, RotateStyle,
SaturateStyle
DarkenStyle,
DesaturateStyle,
LightenStyle,
LightStyle,
RotateStyle,
SaturateStyle,
)

STYLES = LightenStyle, DarkenStyle, SaturateStyle, DesaturateStyle, RotateStyle
Expand Down
10 changes: 8 additions & 2 deletions pygal/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@

from pygal._compat import _ellipsis, u
from pygal.util import (
_swap_curly, majorize, mergextend, minify_css, round_to_float,
round_to_int, template, truncate
_swap_curly,
majorize,
mergextend,
minify_css,
round_to_float,
round_to_int,
template,
truncate,
)


Expand Down
Loading