Skip to content

Use Ruff instead of pyflakes #1728

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

Merged
merged 8 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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