Skip to content

Commit

Permalink
Merge 61a137b into b1356d2
Browse files Browse the repository at this point in the history
  • Loading branch information
gforcada committed Nov 29, 2022
2 parents b1356d2 + 61a137b commit b12cded
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 74 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, 3.8, 3.7, pypy-3.9]
python-version: ["3.11", "3.10", 3.9, 3.8, 3.7, pypy-3.9]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand All @@ -30,27 +30,25 @@ jobs:
run: pip --version
- name: Install dependencies
run: python -m pip install -r requirements.txt
- name: Install itself
run: python -m pip install -e .
# formatters
- name: Run pyupgrade
if: matrix.python-version == '3.9'
if: matrix.python-version == '3.11'
run: pyupgrade --py37-plus setup.py `find z3c -name "*.py"`
- name: Run isort
if: matrix.python-version == '3.9'
if: matrix.python-version == '3.11'
run: isort --check-only setup.py z3c/
- name: Run black
if: matrix.python-version == '3.9'
if: matrix.python-version == '3.11'
run: black --check --skip-string-normalization setup.py z3c/
# linters
- name: Lint with codespell
if: matrix.python-version == '3.9'
if: matrix.python-version == '3.11'
run: codespell *.rst setup.py z3c/
- name: Lint with flake8
if: matrix.python-version == '3.9'
run: flake8 setup.py z3c/ --count --max-complexity=18 --max-line-length=88 --show-source --statistics
if: matrix.python-version == '3.11'
run: flake8 setup.py z3c/ --count --show-source --statistics
# tests and coverage
- name: Test
run: pytest z3c --cov --cov-report term-missing
run: pytest
- name: Coverage
run: coveralls --service=github
23 changes: 2 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
# From https://github.com/github/gitignore/blob/master/Python.gitignore

# Pyc/pyo files.
*.py[co]

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
lib
pyvenv.cfg
var
sdist
develop-eggs
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

#Translations
# *.mo
# ^^^ No, django needs the .mo files as it doesn't compile them on the fly.

#Mr Developer
.mr.developer.cfg

# Ignore generated apache config files
etc/*.apache.conf
htmlcov/
6 changes: 5 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ Changelog of z3c.dependencychecker
- Replace travis for GitHub actions.
[gforcada]

- Test against python 3.7-3.9 and pypy3.
- Test against python 3.7-3.11 and pypy3.
[gforcada]

- Updated developer documentation.
[reinout]


2.7 (2018-08-08)
----------------

Expand Down
27 changes: 27 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,30 @@ requests in the github issue tracker.
Every time you commit something, ``bin/code-analysis`` is automatically
run. Pay attention to the output and fix the problems that are reported. Or
fix the setup so that inappropriate reports are filtered out.


Local development setup
-----------------------

Create a virtualenv and install the requirements::

$ python3 -m venv .
$ bin/pip install -r requirements.txt

If you changed the actual requirements in ``setup.py`` or the development
requirements in ``requirements.in``, re-generate ``requirements.txt``::

$ bin/pip-compile requirements.in

To run the tests (there's some pytest configuration in ``setup.cfg``)::

$ bin/pytest

Some checks that are run by github actions::

$ bin/black --skip-string-normalization
$ bin/codespell setup.py z3c/
$ bin/flake8 setup.py z3c/

Note that the string quoting style is currently not black-standard, so you'll
have to manage it yourself.
7 changes: 4 additions & 3 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
stdlib-list
cached-property
toml
# Ourselves, including our dependencies
-e file:.#z3c.dependencychecker[test]

# Development tools
black
codespell
coveralls
Expand All @@ -17,6 +17,7 @@ flake8-quotes
flake8-todo
importlib-metadata; python_version < '3.8'
isort
pip-tools
pytest
pytest-cov
pyupgrade
Expand Down
33 changes: 27 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
#
# pip-compile requirements.in
#
-e file:.#z3c.dependencychecker
# via -r requirements.in
attrs==22.1.0
# via
# flake8-bugbear
# pytest
black==22.10.0
# via -r requirements.in
build==0.9.0
# via pip-tools
cached-property==1.5.2
# via -r requirements.in
# via z3c-dependencychecker
certifi==2022.9.24
# via requests
charset-normalizer==2.1.1
# via requests
click==8.1.3
# via black
# via
# black
# pip-tools
codespell==2.2.2
# via -r requirements.in
coverage[toml]==6.5.0
Expand Down Expand Up @@ -65,6 +71,7 @@ idna==3.4
importlib-metadata==4.2.0 ; python_version < "3.8"
# via
# -r requirements.in
# build
# click
# flake8
# flake8-comprehensions
Expand All @@ -81,9 +88,15 @@ mccabe==0.7.0
mypy-extensions==0.4.3
# via black
packaging==21.3
# via pytest
# via
# build
# pytest
pathspec==0.10.1
# via black
pep517==0.13.0
# via build
pip-tools==6.10.0
# via -r requirements.in
platformdirs==2.5.2
# via black
pluggy==1.0.0
Expand All @@ -101,21 +114,23 @@ pytest==7.2.0
# via
# -r requirements.in
# pytest-cov
# z3c-dependencychecker
pytest-cov==4.0.0
# via -r requirements.in
pyupgrade==3.1.0
# via -r requirements.in
requests==2.28.1
# via coveralls
stdlib-list==0.8.0
# via -r requirements.in
# via z3c-dependencychecker
tokenize-rt==5.0.0
# via pyupgrade
toml==0.10.2
# via -r requirements.in
# via z3c-dependencychecker
tomli==2.0.1
# via
# black
# build
# coverage
# pytest
typed-ast==1.5.4 ; python_version < "3.8"
Expand All @@ -128,7 +143,13 @@ typing-extensions==4.4.0
# importlib-metadata
urllib3==1.26.12
# via requests
zipp==3.10.0 ; python_version < "3.8"
wheel==0.38.4
# via pip-tools
zipp==3.11.0 ; python_version < "3.8"
# via
# -r requirements.in
# importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ extra-message = [ci skip]
[isort]
profile = black

[tool:pytest]
addopts = --cov --cov-report term-missing --cache-clear z3c/

[flake8]
max-line-length = 88
max-complexity = 18
ignore = E501, # black takes care of line length
W503, # black takes care of where to break lines
D202, # black takes care of blank lines
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def read(filename):
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Quality Assurance',
Expand All @@ -57,7 +59,7 @@ def read(filename):
zip_safe=False,
install_requires=[
'setuptools',
'stdlib-list',
'stdlib-list; python_version < "3.10"',
'cached-property',
'toml',
],
Expand Down
29 changes: 20 additions & 9 deletions z3c/dependencychecker/db.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import logging
import sys

from stdlib_list import stdlib_list

from z3c.dependencychecker.dotted_name import DottedName

logger = logging.getLogger(__name__)


# starting from python 3.10 the list of builtin methods are available directly
PY_10_OR_HIGHER = True
if sys.version_info[1] < 10:
PY_10_OR_HIGHER = False
from stdlib_list import stdlib_list


class ImportsDatabase:
"""Store all imports and requirements of a package
Expand Down Expand Up @@ -37,7 +42,7 @@ def add_extra_requirements(self, extra_name, dotted_names):
only_extra_dotted_names,
)

logger.warn(
logger.warning(
'extra requirement "%s" is declared twice in setup.py',
extra_name,
)
Expand Down Expand Up @@ -349,13 +354,19 @@ def _discard_if_found_obj_in_list(obj, obj_list):

@staticmethod
def _build_std_library():
python_version = sys.version_info
libraries = stdlib_list(
'{}.{}'.format(
python_version[0],
python_version[1],
if PY_10_OR_HIGHER:
# see https://github.com/jackmaney/python-stdlib-list/issues/55
libraries = list(
set(list(sys.stdlib_module_names) + list(sys.builtin_module_names))
)
else:
python_version = sys.version_info
libraries = stdlib_list(
'{}.{}'.format(
python_version[0],
python_version[1],
)
)
)

fake_std_libraries = [DottedName(x) for x in libraries]
return fake_std_libraries
Expand Down
6 changes: 5 additions & 1 deletion z3c/dependencychecker/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import sys
import tempfile
from unittest import mock
Expand Down Expand Up @@ -71,7 +72,10 @@ def test_get_path_no_path_given():
with change_dir(folder):
path = get_path(arguments)

assert path == folder
# realpath() below is used to work around a small mac tempdir naming
# issue. /var/folders/xyz is the tempdir, but after cd'ing you're in
# /private/var/folders/xyz...
assert os.path.realpath(path) == os.path.realpath(folder)


def test_get_path_path_given():
Expand Down
Loading

0 comments on commit b12cded

Please sign in to comment.