Skip to content

Commit

Permalink
Merge branch 'gh_94' into 'modernize_202409'
Browse files Browse the repository at this point in the history
Update deps and modernize #94

See merge request gh/peeringdb/peeringdb-py!28
  • Loading branch information
grizz committed Oct 18, 2024
2 parents 9675683 + 4fe72b0 commit 056f692
Show file tree
Hide file tree
Showing 23 changed files with 1,782 additions and 210 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install virtualenv from poetry
uses: 20c/workflows/poetry@v1
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: install project
run: uv sync --all-extras --dev
- name: Run linters
run: |
poetry run isort src/
poetry run black --check src/
uv run pre-commit run --all-files
test:
needs: linting
Expand All @@ -25,18 +26,17 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Install virtualenv from poetry
uses: 20c/workflows/poetry@v1
with:
python-version: ${{ matrix.python-version }}
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Install python
run: uv python install ${{ matrix.python-version }}
- name: install tox
run: uv sync --all-extras --dev
- name: Run tests
run: |
poetry run pytest -vv --cov-report=term-missing --cov=peeringdb --cov-report=xml tests/
poetry run coverage report
run: uv run tox
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ dist/
site/
venv/
.DS_Store
.venv

27 changes: 6 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,17 @@ repos:
hooks:
- id: check-yaml
- id: trailing-whitespace
- repo: local
hooks:
- id: system
name: isort
entry: poetry run isort .
language: system
pass_filenames: false
- repo: local
hooks:
- id: pyupgrade
name: pyupgrade
entry: poetry run pyupgrade --py36-plus
entry: uv run pyupgrade --py36-plus
language: python
types: [python]
pass_filenames: true
- repo: local
hooks:
- id: system
name: Black
entry: poetry run black .
language: system
pass_filenames: false
- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: system
name: flake8
entry: poetry run flake8 .
language: system
pass_filenames: false
- id: ruff
args: [--fix]
- id: ruff-format
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

## Unreleased
### Fixed
- handle api data errors more gracefully, allowing to skip broken objects and retry them later (#95)


## 2.2.0
### Fixed
- Client should handle rate limiting errors gracefully


Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Unreleased:
security: []
2.2.0:
fixed:
- Client should handle rate limiting errors gracefully
- Client should handle rate limiting errors gracefully (#76)
2.1.1:
fixed:
- fix pyproject.toml version
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ site_description: PeeringDB facilitates the exchange of information related to P
repo_url: https://github.com/peeringdb/peeringdb-py

theme: readthedocs
pages:
nav:
- Home: 'index.md'
- CLI: 'cli.md'
- API: 'api.md'
Expand Down
97 changes: 47 additions & 50 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[build-system]
requires = [ "poetry>=0.12",]
build-backend = "poetry.masonry.api"

[tool.poetry]
[project]
name = "peeringdb"
version = "2.2.0"
description = "PeeringDB Django models"
readme = "README.md"
repository = "https://github.com/peeringdb/peeringdb-py"
authors = [ "PeeringDB <[email protected]>",]
authors = [{ name = "PeeringDB", email = "[email protected]" }]
license = "Apache-2.0"
requires-python = ">=3.8"

classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Intended Audience :: Telecommunications Industry",
Expand All @@ -22,56 +22,53 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet"
]
[[tool.poetry.packages]]
include = "peeringdb"
from = "src"

[tool.isort]
profile = "black"
multi_line_output = 3
dependencies = [
"confu>=1",
"munge[toml,tomlkit,yaml]>=1.2.0",
"twentyc.rpc>=1",
"pyyaml>=6.0.1",
"httpx>=0.24.1"
]

[tool.poetry.scripts]
[project.optional-dependencies]
dev = [
"django_peeringdb>=3.1.0",
"django>=4.2",
"pytest>=8",
"pytest-cov >= 5",
"tox>=4",
"tox-gh-actions >= 3",
"tox-uv>=1.13.0",
"mypy>=0.950",
"pre-commit>=2.13",
"pyupgrade>=2.19",
"ruff>=0.1",
"markdown",
"markdown-include>=0.5,<1",
"mkdocs>=1.2.3",
"ctl>=1",
"jinja2>=3",
"tmpl>=1",
"twine>=3"
]
[project.scripts]
peeringdb = "peeringdb.cli:main"

[tool.poetry.dependencies]
python = "^3.8"
confu = "^1"
munge = { extras = ["tomlkit", "yaml"], version = "^1.2.0" }
"twentyc.rpc" = "^1"
pyyaml = "^6.0.1"
httpx = ">=0.24.1"

[tool.poetry.dev-dependencies]

# testing
django_peeringdb = "^3.1.0"
django = "~4.2"

pytest = "^6.0.1"
pytest-cov = "*"
tox = ">=3.24"

# linting
black = ">=20"
isort = "^5.7.0"
flake8 = "^3.8.4"
mypy = "^0.950"
pre-commit = "^2.13"
pyupgrade = "^2.19.4"

# docs
markdown = "*"
markdown-include = ">=0.5,<1"
mkdocs = "^1.2.3"
[[project.packages]]
include = "peeringdb"
from = "src"

# ctl
ctl = "^1"
jinja2 = "^3"
tmpl = "^1"
twine = "^3.3.0"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.poetry.plugins."markdown.extensions"]
[project.plugins."markdown.extensions"]
pymdgen = "pymdgen.md:Extension"

[[project.source]]
name = "pypi-public"
url = "https://pypi.org/simple/"
40 changes: 0 additions & 40 deletions script/dump_serialized.py

This file was deleted.

10 changes: 4 additions & 6 deletions src/peeringdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

import logging
import sys
from distutils.util import strtobool
from importlib import import_module
from importlib import metadata as importlib_metadata

import pkg_resources
from peeringdb.util import get_log_level, str_to_bool

from peeringdb.util import get_log_level

__version__ = pkg_resources.require("peeringdb")[0].version
__version__ = importlib_metadata.version("peeringdb")
_log_level = logging.INFO


Expand All @@ -36,7 +34,7 @@ def _config_logs(level=None, name=None, allow_other_loggers=False):

if not isinstance(allow_other_loggers, bool):
try:
allow_other_loggers = strtobool(str(allow_other_loggers))
allow_other_loggers = str_to_bool(str(allow_other_loggers))
except Exception:
allow_other_loggers = False

Expand Down
5 changes: 2 additions & 3 deletions src/peeringdb/_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"""

import logging
import sys
from datetime import datetime
from typing import List, Union

from peeringdb import config, get_backend
from peeringdb import get_backend
from peeringdb._sync import extract_relations, set_many_relations, set_single_relations
from peeringdb.fetch import Fetcher
from peeringdb.private import private_data_has_been_fetched
from peeringdb.util import group_fields, log_error
from peeringdb import config


class Updater:
Expand Down Expand Up @@ -160,7 +160,6 @@ def _handle_initial_sync(self, entries: list, res):
"""

objs = []
retry = []
for row in entries:
try:
obj, _ = self.create_obj(row, res)
Expand Down
9 changes: 6 additions & 3 deletions src/peeringdb/commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import io
import logging
import os
import subprocess
Expand All @@ -13,6 +12,10 @@
from peeringdb.output._dict import dump_python_dict
from peeringdb.util import load_failed_entries, save_failed_entries
from peeringdb.whois import WhoisFormat
from peeringdb.util import load_failed_entries, save_failed_entries


_log = logging.getLogger(__name__)

_log = logging.getLogger(__name__)

Expand Down Expand Up @@ -106,7 +109,7 @@ def handle(config, poids, output_format, depth, remote, **_):
try:
codec = munge.get_codec(output_format)()
codec.dump(dump_python_dict(obj, depth), sys.stdout)
except TypeError as e:
except TypeError:
print(f"Output format not supported: {output_format}", file=sys.stderr)
return 1

Expand Down Expand Up @@ -142,7 +145,7 @@ def handle(config, poids, **_):
print(f"Not found: {tag}={key}: {e}", file=sys.stderr)
return 1
if len(objs) == 0:
print(f"Not found: {tag}={key}:", file=sys.stderr)
print(f"Not found: {tag}={key}: ", file=sys.stderr)
return 1

fmt.display(tag, objs[0])
Expand Down
2 changes: 1 addition & 1 deletion src/peeringdb/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _get(self, endpoint: str, **params):
resp = requests.get(url, timeout=self.timeout, headers=headers)
resp.raise_for_status()
return resp.json()["data"]
except requests.exceptions.HTTPError as e:
except requests.exceptions.HTTPError:
if resp.status_code == 429:
retry_after = min(2**self.attempt, 60)
self._log.info(
Expand Down
1 change: 0 additions & 1 deletion src/peeringdb/output/_dict.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from datetime import datetime
from decimal import Decimal
from ipaddress import IPv4Address, IPv6Address
Expand Down
Loading

0 comments on commit 056f692

Please sign in to comment.