diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index c2a211c..3407e7d 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -6,7 +6,7 @@ labels: 'bug' ### Environment information * Python Version: x.x.x -* OS: osx/linux/win +* OS: macOS/linux/win Python environment diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 38bee12..996197d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,14 +1,18 @@ ### What I did + -Related issue: # + +fixes: # ### How I did it + ### How to verify it + ### Checklist + -- [ ] Passes all linting checks (pre-commit and CI jobs) -- [ ] New test cases have been added and are passing +- [ ] All changes are completed +- [ ] New test cases have been added - [ ] Documentation has been updated -- [ ] PR title follows [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) standard (will be automatically included in the changelog) diff --git a/.gitignore b/.gitignore index 700eaf1..0b51dc5 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST +*.swp +.DS_Store # PyInstaller # Usually these files are written by a python script from a template diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf3232b..a267258 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,32 +4,27 @@ repos: hooks: - id: check-yaml -- repo: https://github.com/asottile/seed-isort-config - rev: v2.2.0 - hooks: - - id: seed-isort-config - - repo: https://github.com/pre-commit/mirrors-isort rev: v5.10.1 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.6.0 hooks: - id: black name: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.2 + rev: 4.0.1 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.950 + rev: v0.971 hooks: - id: mypy - + additional_dependencies: [types-requests] default_language_version: python: python3 diff --git a/README.md b/README.md index e105bb1..9dc879f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Dependencies -* [python3](https://www.python.org/downloads/release/python-368/) version 3.6 or greater, python3-dev +* [python3](https://www.python.org/downloads/release/python-368/) version 3.7.2 or greater, python3-dev ## Installation @@ -42,7 +42,9 @@ python3 setup.py install ## Development -This project is in early development and should be considered an alpha. Things might not work, breaking changes are likely. Comments, questions, criticisms and pull requests are welcomed. +This project is in early development and should be considered an alpha. +Things might not work, breaking changes are likely. +Comments, questions, criticisms and pull requests are welcomed. ## License diff --git a/pyproject.toml b/pyproject.toml index 5c7d106..26e1f3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ - [build-system] +[build-system] requires = ["setuptools>=51.1.1", "wheel", "setuptools_scm[toml]>=5.0"] [tool.mypy] @@ -36,7 +36,5 @@ markers = "fuzzing: Run Hypothesis fuzz test suite" line_length = 100 force_grid_wrap = 0 include_trailing_comma = true -known_third_party = ["click", "github", "hypothesis", "hypothesis_jsonschema", "pydantic", "pytest", "requests", "semantic_version", "setuptools"] -known_first_party = ["tokenlists"] multi_line_output = 3 use_parentheses = true diff --git a/setup.py b/setup.py index 8df85fe..c6cca95 100644 --- a/setup.py +++ b/setup.py @@ -5,18 +5,19 @@ extras_require = { "test": [ # `test` GitHub Action jobs uses this - "pytest>=6.0,<7.0", # Core testing package + "pytest>=6.0", # Core testing package "pytest-xdist", # multi-process runner "pytest-cov", # Coverage analyzer plugin - "hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer - "PyGithub>=1.54,<2.0", # Necessary to pull official schema from github + "hypothesis>=6.2.0,<7", # Strategy-based fuzzer + "PyGithub>=1.54,<2", # Necessary to pull official schema from github "hypothesis-jsonschema==0.19.0", # Fuzzes based on a json schema ], "lint": [ - "black>=22.3.0,<23.0", # auto-formatter and linter - "mypy>=0.950,<1.0", # Static type analyzer - "flake8>=4.0.1,<5.0", # Style linter - "isort>=5.10.1,<6.0", # Import sorting linter + "black>=22.6.0,<23", # auto-formatter and linter + "mypy>=0.971,<1", # Static type analyzer + "types-requests", # Needed due to mypy typeshed + "flake8>=4.0.1,<5", # Style linter + "isort>=5.10.1,<6", # Import sorting linter ], "doc": [ "Sphinx>=3.4.3,<4", # Documentation generator @@ -48,6 +49,7 @@ with open("./README.md") as readme: long_description = readme.read() + setup( name="tokenlists", use_scm_version=True, @@ -62,10 +64,11 @@ python_requires=">=3.7.2,<3.11", install_requires=[ "importlib-metadata ; python_version<'3.8'", - "click>=8.0.1", - "pydantic>=1.9.0,<2.0.0", - "pyyaml>=6.0,<7.0", - "semantic-version>=2.9.0,<3", + "click>=8.1.3,<9", + "pydantic>=1.9.2,<2", + "pyyaml>=6.0,<7", + "semantic-version>=2.10.0,<3", + "requests>=2.28.1,<3", ], entry_points={"console_scripts": ["tokenlists=tokenlists._cli:cli"]}, extras_require=extras_require, diff --git a/tests/functional/test_schema_fuzzing.py b/tests/functional/test_schema_fuzzing.py index 3b93118..67e30db 100644 --- a/tests/functional/test_schema_fuzzing.py +++ b/tests/functional/test_schema_fuzzing.py @@ -1,5 +1,5 @@ import pytest -import requests # type: ignore +import requests from hypothesis import HealthCheck, given, settings from hypothesis_jsonschema import from_schema from pydantic import ValidationError diff --git a/tests/functional/test_uniswap_examples.py b/tests/functional/test_uniswap_examples.py index bd69e85..5937d6d 100644 --- a/tests/functional/test_uniswap_examples.py +++ b/tests/functional/test_uniswap_examples.py @@ -1,15 +1,14 @@ import os import github -import pytest # type: ignore -import requests # type: ignore +import pytest +import requests from pydantic import ValidationError from tokenlists import TokenList # NOTE: Must export GITHUB_ACCESS_TOKEN UNISWAP_REPO = github.Github(os.environ["GITHUB_ACCESS_TOKEN"]).get_repo("Uniswap/token-lists") - UNISWAP_RAW_URL = "https://raw.githubusercontent.com/Uniswap/token-lists/master/test/schema/" @@ -20,6 +19,13 @@ def test_uniswap_tokenlists(token_list_name): token_list = requests.get(UNISWAP_RAW_URL + token_list_name).json() + if token_list_name in ( + "example-crosschain.tokenlist.json", + "extensions-valid-object.tokenlist.json", + ): + # TODO: Unskip once can handle object extensions + pytest.skip("https://github.com/ApeWorX/py-tokenlists/issues/20") + if "invalid" not in token_list_name: assert TokenList.parse_obj(token_list).dict() == token_list diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 8a2939c..83eb44b 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,6 +1,6 @@ from pathlib import Path -import pytest # type: ignore +import pytest from click.testing import CliRunner from tokenlists import _cli, config diff --git a/tokenlists/_cli.py b/tokenlists/_cli.py index 21fbfb5..2ca4b3e 100644 --- a/tokenlists/_cli.py +++ b/tokenlists/_cli.py @@ -15,7 +15,7 @@ def choices(self): return list(TokenListManager().available_tokenlists()) -@click.group() +@click.group(short_help="Work with token lists") @click.version_option(message="%(version)s", package_name="tokenlists") def cli(): """ @@ -41,7 +41,6 @@ def _list(): @click.argument("uri") def install(uri): manager = TokenListManager() - manager.install_tokenlist(uri) @@ -49,7 +48,6 @@ def install(uri): @click.argument("name", type=TokenlistChoice()) def remove(name): manager = TokenListManager() - manager.remove_tokenlist(name) @@ -57,9 +55,7 @@ def remove(name): @click.argument("name", type=TokenlistChoice()) def set_default(name): manager = TokenListManager() - manager.set_default_tokenlist(name) - click.echo(f"Default tokenlist is now: '{manager.default_tokenlist}'") diff --git a/tokenlists/manager.py b/tokenlists/manager.py index 4152ac4..af4ce6f 100644 --- a/tokenlists/manager.py +++ b/tokenlists/manager.py @@ -1,6 +1,6 @@ from typing import Iterator, List, Optional -import requests # type: ignore +import requests from tokenlists import config from tokenlists.typing import ChainId, TokenInfo, TokenList, TokenSymbol