Skip to content

Commit

Permalink
Merge pull request #95 from reinout/reinout-dev-documentation
Browse files Browse the repository at this point in the history
Dev documentation + setup
  • Loading branch information
reinout committed Nov 29, 2022
2 parents b1356d2 + 1128e6d commit b051628
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 54 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ 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'
Expand All @@ -48,9 +46,9 @@ jobs:
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
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/
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Changelog of z3c.dependencychecker
- Test against python 3.7-3.9 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
52 changes: 27 additions & 25 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
#
# This file is autogenerated by pip-compile with python 3.7
# This file is autogenerated by pip-compile with python 3.8
# To update, run:
#
# 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 @@ -62,14 +68,6 @@ flake8-todo==0.7
# via -r requirements.in
idna==3.4
# via requests
importlib-metadata==4.2.0 ; python_version < "3.8"
# via
# -r requirements.in
# click
# flake8
# flake8-comprehensions
# pluggy
# pytest
iniconfig==1.1.1
# via pytest
isort==5.10.1
Expand All @@ -81,9 +79,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,34 +105,32 @@ 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"
# via
# -r requirements.in
# black
typing-extensions==4.4.0
# via
# black
# importlib-metadata
# via black
urllib3==1.26.12
# via requests
zipp==3.10.0 ; python_version < "3.8"
# via
# -r requirements.in
# importlib-metadata
wheel==0.38.4
# via pip-tools

# 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
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
24 changes: 24 additions & 0 deletions z3c/dependencychecker/tests/test_user_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ def test_one_user_mapping(minimal_structure):
} == mappings


def test_filter_out_mappings_on_test(minimal_structure):
path, package_name = minimal_structure
_write_user_config(path, ONE_MAPPING)
_update_requires_txt(
path,
package_name,
['plone.reload', '[test]', 'Zope2'],
)
package = Package(path)
package.inspect()
five_dotted_name = DottedName('Products.Five')
plone_reload_dotted_name = DottedName('plone.reload')
zope_dotted_name = DottedName('Zope2')

assert len(package.imports.user_mappings) == 1
assert zope_dotted_name in package.imports.user_mappings

# The next two aren'd in the mapping, so they shouldn't be filtered out:
assert package.imports._filter_out_mappings_on_test(plone_reload_dotted_name)
assert package.imports._filter_out_mappings_on_test(five_dotted_name)
# This one is in the mapping, but shouldn't be filtered out as it is a test-only import.
assert package.imports._filter_out_mappings_on_test(zope_dotted_name)


def test_more_user_mappings(minimal_structure):
path, package_name = minimal_structure
_write_user_config(path, MORE_MAPPINGS)
Expand Down

0 comments on commit b051628

Please sign in to comment.