Skip to content

Commit

Permalink
Merge pull request #1728 from ocefpaf/ruff
Browse files Browse the repository at this point in the history
Use Ruff instead of pyflakes
  • Loading branch information
ocefpaf committed Mar 6, 2023
2 parents 11187ff + 319d3bf commit cf5f834
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 71 deletions.
28 changes: 6 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: examples/data/|.*\.css|.*\.json|.*\.geojson|.*\.html

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-ast
Expand All @@ -14,22 +14,13 @@ repos:
- id: file-contents-sorter
files: requirements-dev.txt

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.247
hooks:
- id: flake8
exclude: docs/conf.py
args: [--max-line-length=120]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
additional_dependencies: [toml]
args: ["--profile", "black", "--filter-files"]
- id: ruff

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.1.0
hooks:
- id: black
language_version: python3
Expand All @@ -44,16 +35,9 @@ repos:
hooks:
- id: codespell
args:
- --ignore-words-list=thex
- --ignore-words-list=thex,nd,fo,som,nam,tha
exclude: >
(?x)^(
.*\.csv |
.*\.json |
)$
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
hooks:
- id: pyupgrade
args:
- --py36-plus
25 changes: 0 additions & 25 deletions folium/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

import branca
from branca.colormap import ColorMap, LinearColormap, StepColormap
from branca.element import (
Expand Down Expand Up @@ -59,29 +57,6 @@
)


if sys.version_info < (3, 0):
raise ImportError(
"""You are running folium {} on Python 2
folium 0.9 and above are no longer compatible with Python 2, but somehow
you got this version anyway. Make sure you have pip >= 9.0 to avoid this
kind of issue, as well as setuptools >= 24.2:
$ pip install pip setuptools --upgrade
Your choices:
- Upgrade to Python 3.
- Install an older version of folium:
$ pip install 'folium<0.9.0'
""".format(
__version__
)
) # noqa

__all__ = [
"Choropleth",
"ClickForMarker",
Expand Down
1 change: 0 additions & 1 deletion folium/folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@


class GlobalSwitches(Element):

_template = Template(
"""
<script>
Expand Down
1 change: 0 additions & 1 deletion folium/plugins/measure_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def __init__(
secondary_area_unit="acres",
**kwargs
):

super().__init__()
self._name = "MeasureControl"

Expand Down
1 change: 0 additions & 1 deletion folium/plugins/minimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def __init__(
minimized=False,
**kwargs
):

super().__init__()
self._name = "MiniMap"

Expand Down
1 change: 0 additions & 1 deletion folium/plugins/mouse_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def __init__(
lng_formatter=None,
**kwargs
):

super().__init__()
self._name = "MousePosition"

Expand Down
1 change: 0 additions & 1 deletion folium/raster_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def __init__(
opacity: float = 1,
**kwargs
):

# check for xyzservices.TileProvider without importing it
if isinstance(tiles, dict):
attr = attr if attr else tiles.html_attribution # type: ignore
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ color = true

[tool.mypy]
ignore_missing_imports = true

[tool.ruff]
select = [
"F", # flakes
"I", # import sorting
"U", # upgrade
]
target-version = "py37"
line-length = 120

[tool.ruff.per-file-ignores]
"docs/conf.py" = ["E402"]
19 changes: 0 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
import os
import sys

from setuptools import setup

rootpath = os.path.abspath(os.path.dirname(__file__))

if sys.version_info < (3, 5):
error = """
folium 0.9+ supports Python 3.5 and above.
When using Python 2.7, please install folium 0.8.*.
See folium `README.rst` file for more information:
https://github.com/python-visualization/folium/blob/main/README.rst
Python {py} detected.
Try upgrading pip and retry.
""".format(
py=".".join([str(v) for v in sys.version_info[:3]])
)
print(error, file=sys.stderr)
sys.exit(1)


def read(*parts):
return open(os.path.join(rootpath, *parts)).read()
Expand Down

0 comments on commit cf5f834

Please sign in to comment.