Skip to content

Commit

Permalink
Merge pull request #29 from 20c/update-codecov
Browse files Browse the repository at this point in the history
Update codecov, fix tests
  • Loading branch information
grizz authored Jul 6, 2024
2 parents 0d22a40 + ce7dbb3 commit 22d5b5e
Show file tree
Hide file tree
Showing 18 changed files with 609 additions and 676 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install virtualenv from poetry
uses: 20c/workflows/poetry@v1
- name: Run linters
Expand All @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest" ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
Expand All @@ -32,6 +32,7 @@ jobs:
- name: Run tests
run: poetry run tox -e py
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
33 changes: 14 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
fail_fast: false
exclude: |
(?x)^(
tests/data/.*
)$
(?x)^(
tests/data/.*
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: trailing-whitespace
- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.1
hooks:
- id: system
name: isort
entry: poetry run isort .
language: system
pass_filenames: false
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
- repo: local
hooks:
- id: pyupgrade
- id: pyupgrade
name: pyupgrade
entry: poetry run pyupgrade --py37-plus
entry: poetry run pyupgrade --py38-plus
language: python
types: [python]
pass_filenames: true
- repo: local
hooks:
- id: system
name: Black
entry: poetry run black .
language: system
pass_filenames: false
6 changes: 4 additions & 2 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased:
added: []
fixed: []
added:
- support for py3.12
fixed:
- finding data file in tests
changed: []
deprecated: []
removed: []
Expand Down
1,176 changes: 558 additions & 618 deletions poetry.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ click = ">=5.1"
coverage = ">=5"
pytest = ">=6"
pytest-django = ">=3.8"
pytest-filedata = "^0.4.0"
pytest-filedata = ">=1"
pytest-cov = "*"
tox = ">=3.20"
tox-gh-actions = "^2.9.1"
tox-gh-actions = ">=2.9.1"
toml = ">=0.10.2"
tomlkit = ">=0.7.2"

# linting
black = ">=20"
isort = ">=5.7"
flake8 = ">=3.8"
mypy = ">=0.950"
pre-commit = ">=2.13"
pyupgrade = ">=2.19"
ruff = ">=0.1"

# docs
markdown = "*"
Expand All @@ -64,7 +64,7 @@ tomlkit = [ "tomlkit",]
yaml = [ "PyYAML",]

[tool.poetry.dependencies.PyYAML]
version = ">=5.1"
version = ">=6.0.1"
optional = true

[tool.poetry.dependencies.toml]
Expand Down
2 changes: 1 addition & 1 deletion src/munge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .codec import get_codec # noqa
from .codec import get_codecs # noqa
from .codec import load_datafile # noqa
from .config import Config
from .config import Config # noqa

if not globals().get("MUNGE_EXPLICIT_IMPORT", False):
from .codec import all # noqa
Expand Down
4 changes: 2 additions & 2 deletions src/munge/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import collections
import sys
from collections.abc import Mapping
from urllib.parse import urlsplit

import requests
Expand Down Expand Up @@ -48,7 +48,7 @@ def set_type(self, name, typ):
raise NotImplementedError("set_type has not been implemented")

def supports_data(self, data):
if isinstance(data, collections.abc.Mapping):
if isinstance(data, Mapping):
return self.supports_dict
if isinstance(data, list):
return self.supports_list
Expand Down
2 changes: 1 addition & 1 deletion src/munge/codec/all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# import munge.codec.all
# loads and registers all codecs without polluting namespace

from . import *
from . import * # noqa
3 changes: 2 additions & 1 deletion src/munge/codec/toml_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ def dump(self, data, fobj, **kwargs):
def dumps(self, data):
return toml.dumps(data)

except ImportError:
except ImportError as e:
print(f"failed to import toml module: {e}")
pass
3 changes: 2 additions & 1 deletion src/munge/codec/toml_tomlkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ def dump(self, data, fobj, **kwargs):
def dumps(self, data, **kwargs):
return tomlkit.dumps(data)

except ImportError:
except ImportError as e:
print(f"failed to import tomlkit module: {e}")
pass
9 changes: 5 additions & 4 deletions src/munge/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import collections
import copy
import os
from collections import namedtuple
from collections.abc import MutableMapping
from urllib.parse import urlsplit

import munge
Expand All @@ -10,7 +11,7 @@
# this wouldn't work with tabular data
# need metaclass to allow users to set info once on class
# TODO rename to BaseConfig, set standard setup for Config?
class Config(collections.abc.MutableMapping):
class Config(MutableMapping):
"""
class for storing and manipulating data for config files
"""
Expand Down Expand Up @@ -154,7 +155,7 @@ def try_read(self, config_dir=None, **kwargs):
self.read(cdir, **kwargs)
return cdir

except OSError as e:
except OSError:
pass

def write(self, config_dir=None, config_name=None, codec=None):
Expand Down Expand Up @@ -196,7 +197,7 @@ def find_cls(name, extra_schemes={}):
return munge.get_codec(name)


class MungeURL(collections.namedtuple("MungeURL", "cls url")):
class MungeURL(namedtuple("MungeURL", "cls url")):
pass


Expand Down
4 changes: 2 additions & 2 deletions src/munge/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def recursive_update(a, b, **kwargs):
recursive_update(a[k], v, **kwargs)
continue

elif merge_lists and type(v) is list:
if type(a.get(k, None)) is list:
elif merge_lists and isinstance(v, list):
if isinstance(a.get(k, None), list):
if copy:
a[k].extend(deepcopy(v))
else:
Expand Down
2 changes: 0 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

import click
import pytest
from click.testing import CliRunner

import munge.cli
Expand Down
4 changes: 2 additions & 2 deletions tests/test_codecs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import collections
import filecmp
import os
import sys

Expand Down Expand Up @@ -179,6 +178,7 @@ def test_dumpu(codec, dataset, tmpdir):
if not obj.supports_data(dataset.expected):
return
dstfile = tmpdir.join("dump" + obj.extension)
assert dstfile
assert dataset.expected == obj.loads(obj.dumps(dataset.expected))


Expand Down Expand Up @@ -216,7 +216,7 @@ def test_load_datafile(codec, dataset):
munge.load_datafile("nonexistant", data_dir)

# default value
assert None == munge.load_datafile("nonexistant", data_dir, default=None)
assert munge.load_datafile("nonexistant", data_dir, default=None) is None
assert "DEFAULT" == munge.load_datafile("nonexistant", data_dir, default="DEFAULT")

data = munge.load_datafile(dataset.filename, this_dir)
Expand Down
8 changes: 3 additions & 5 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import collections
import copy
import filecmp
import os
import shutil
import sys

import pytest

Expand All @@ -18,6 +14,7 @@

def test_parse_url():
mysql = munge.get_codec("mysql")
assert mysql
json = munge.get_codec("json")
toml = munge.get_codec("toml")

Expand Down Expand Up @@ -123,6 +120,7 @@ def conf0(request):
def test_derived_config_obj(conf):
assert default_config == conf.default()
baseconf = munge.config.Config(**DefaultConfig.defaults)
assert baseconf


def test_config_obj(conf):
Expand Down Expand Up @@ -272,4 +270,4 @@ def test_conf0(conf0):
assert conf0_data["addrbook"]["site0"]["url"] == conf0.get_nested(
"addrbook", "site0", "url"
)
assert None == conf0.get_nested("addrbook", "site1", "url")
assert conf0.get_nested("addrbook", "site1", "url") is None
1 change: 0 additions & 1 deletion tests/test_globals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import importlib
import os
import sys

Expand Down
4 changes: 0 additions & 4 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import copy

import pytest

import munge.util


Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@ python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312


[pytest]
norecursedirs = .ctl .tox .venv data gen


[testenv]
whitelist_externals = poetry
allowlist_externals = poetry
commands =
poetry install -v --all-extras
poetry run pytest -vv --cov="{toxinidir}/src" --cov-report=term-missing --cov-report=xml tests/


[tox]
envlist = py38,py39,py310,py311
envlist = py38,py39,py310,py311,py312
isolated_build = True


Expand Down

0 comments on commit 22d5b5e

Please sign in to comment.