diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1c5dd7c..9114eaa 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install .['test'] + python -m pip install .['dev'] - name: Run mypy run: | mypy ./iscan/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9f30a73..e7886a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,7 @@ repos: - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.3 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.10 hooks: - - id: flake8 - - repo: https://github.com/timothycrosley/isort - rev: 5.1.0 - hooks: - - id: isort + - id: ruff + args: [--fix] + - id: ruff-format diff --git a/iscan/__init__.py b/iscan/__init__.py index eb205e2..3e3ba3a 100644 --- a/iscan/__init__.py +++ b/iscan/__init__.py @@ -1,4 +1,4 @@ from iscan.scan import run -__version__ = '0.4.5' +__version__ = '0.4.6' diff --git a/iscan/std_lib.py b/iscan/std_lib.py index 9d14e50..f9147ed 100644 --- a/iscan/std_lib.py +++ b/iscan/std_lib.py @@ -88,7 +88,9 @@ def get_std_lib(version: str) -> List[str]: resp.raise_for_status() soup = BeautifulSoup(resp.text, 'html.parser') - links = soup.find('table').find_all('a', href=True) + table = soup.find('table') + assert table is not None + links = table.find_all('a', href=True) std_lib = [link.text.split('.')[0] for link in links] return sorted(set(std_lib)) diff --git a/iscan/tests/test_package/foo.py b/iscan/tests/test_package/foo.py index 5c69573..775d8b9 100644 --- a/iscan/tests/test_package/foo.py +++ b/iscan/tests/test_package/foo.py @@ -1,7 +1,6 @@ -"""Import two packages on a single line to see if it breaks the code. -isort:skip_file -""" +"""Import third-party packages to test scanning behaviour.""" import shutil import matplotlib.pyplot as plt -import numpy as np, pandas as pd # noqa: E401 +import numpy as np +import pandas as pd diff --git a/iscan/tests/test_scan.py b/iscan/tests/test_scan.py index a1898b6..aa30a09 100644 --- a/iscan/tests/test_scan.py +++ b/iscan/tests/test_scan.py @@ -3,8 +3,7 @@ import pytest -from iscan.scan import (ImportScanner, convert_source_to_tree, get_base_name, - run, scan_directory, sort_counter) +from iscan.scan import ImportScanner, convert_source_to_tree, get_base_name, run, scan_directory, sort_counter CURRENT_DIR = abspath(dirname(__file__)) diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 1a6191c..0000000 --- a/mypy.ini +++ /dev/null @@ -1,2 +0,0 @@ -[mypy-iscan.tests.*] -ignore_errors = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..084d02b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,50 @@ +[build-system] +requires = ["setuptools>=61"] +build-backend = "setuptools.build_meta" + +[project] +name = "iscan" +dynamic = ["version"] +description = "iscan helps you identify your project's dependencies." +readme = "README.md" +requires-python = ">=3.10" +license = {file = "LICENSE"} +authors = [ + {name = "Zhengnan Zhao"} +] +classifiers = [ + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +urls.Repository = "https://github.com/zzhengnan/iscan" +scripts.iscan = "iscan.scan:main" +optional-dependencies.build = ["setuptools", "twine", "wheel"] +optional-dependencies.dev = [ + "beautifulsoup4", + "coverage", + "mypy", + "pre-commit", + "pytest", + "requests", + "ruff", +] + +[tool.setuptools.dynamic] +version = {attr = "iscan.__version__"} + +[tool.ruff] +line-length = 120 +exclude = ["build", "dist", "iscan/std_lib.py"] +lint.select = ["E", "F", "I"] +lint.ignore = ["F401"] +lint.isort.known-first-party = ["iscan"] +lint.isort.lines-between-types = 0 +lint.isort.lines-after-imports = 2 + +[tool.mypy] +overrides = [{module = "iscan.tests.*", ignore_errors = true}] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 15cac82..0000000 --- a/setup.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[flake8] -max-line-length = 120 -exclude = - build/, - dist/, - iscan/std_lib.py, -ignore = F401 # Unused imports - -[isort] -known_first_party = isort -lines_between_types = 0 -lines_after_imports = 2 diff --git a/setup.py b/setup.py deleted file mode 100644 index 3285ef6..0000000 --- a/setup.py +++ /dev/null @@ -1,40 +0,0 @@ -import setuptools - -import iscan - - -with open('README.md', 'r') as f: - LONG_DESCRIPTION = f.read() - - -EXTRAS_REQUIRE = { - 'build': ['setuptools', 'twine', 'wheel'], - 'qa': ['flake8', 'isort', 'pre-commit'], - 'test': ['coverage', 'mypy', 'pytest'], - 'util': ['beautifulsoup4', 'requests'] # To scrape standard library modules -} -EXTRAS_REQUIRE['dev'] = EXTRAS_REQUIRE['build'] + EXTRAS_REQUIRE['qa'] + EXTRAS_REQUIRE['test'] + EXTRAS_REQUIRE['util'] - - -setuptools.setup( - name='iscan', - version=iscan.__version__, - url='https://github.com/zzhengnan/iscan', - author='Zhengnan Zhao', - description="iscan helps you identify your project's dependencies.", - long_description=LONG_DESCRIPTION, - long_description_content_type='text/markdown', - packages=setuptools.find_packages(), - entry_points={'console_scripts': ['iscan=iscan.scan:main']}, - python_requires='>=3.10', - extras_require=EXTRAS_REQUIRE, - classifiers=[ - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: 3.13', - 'Programming Language :: Python :: 3.14', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - ] -)