Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI (plus DX improvements) #2171

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,11 @@ jobs:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install mypy
- name: Static type checking with mypy
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: mypy
run: mypy --install-types --non-interactive --config mypy.ini faker
python -m pip install tox
- name: Run mypy
run: tox
env:
TOXENV: mypy

test_ubuntu:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Making Changes
the new branch with ``git checkout fix/master/my_contribution``.
Please avoid working directly on the ``master`` branch.
- Make commits of logical units.
- Install the development requirements: ``python -m pip install -e .[dev]``
- Follow our `coding style`_. You can run ``make lint`` to format your code.
- Check for unnecessary whitespace with ``git diff --check`` before
committing.
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ mypy:
mypy --install-types --non-interactive --config mypy.ini faker

black:
black --line-length 120 .
black .

isort:
isort --atomic .

generate-stubs:
python3.10 generate_stubs.py
generate-stubs:
python3.11 generate_stubs.py
black faker/proxy.pyi
isort faker/proxy.pyi


lint: generate-stubs isort black mypy flake8

Expand Down
2 changes: 1 addition & 1 deletion docs/coding_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ We use the black code style with a line length of 120 characters and trailing co

You can format the code with::

black --line-length 120
black .

Please include `type hints`_ for every provider method you write. An overview of generic types is included below.

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 120
30 changes: 30 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@
except AttributeError:
zip_safe = False

extra_test = [
"coverage>=5.2",
"freezegun",
"pytest>=6.0.1",
"ukpostcodeparser>=1.1.1",
"validators>=0.13.0",
"sphinx>=2.4,<3.0",
"Pillow",
"xmltodict",
]
extra_flake8 = ["flake8>=4.0.0", "flake8-comprehensions"]
extra_check_manifest = ["check-manifest"]
extra_isort = ["isort"]
extra_mypy = ["mypy==1.14.1"]
extra_black = ["black==24.4.0"]
extra_doc8 = ["doc8"]
extra_dev = list(
set(extra_test + extra_flake8 + extra_check_manifest + extra_isort + extra_mypy + extra_black + extra_doc8)
)

setup(
name="Faker",
version=VERSION,
Expand Down Expand Up @@ -71,4 +91,14 @@
install_requires=[
"python-dateutil>=2.4",
],
extras_require={
"test": extra_test,
"flake8": extra_flake8,
"check-manifest": extra_check_manifest,
"isort": extra_isort,
"mypy": extra_mypy,
"black": extra_black,
"doc8": extra_doc8,
"dev": extra_dev,
},
)
31 changes: 9 additions & 22 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,42 @@ envlist=py{39,310,311,312,313,py3},alpine,flake8,checkmanifest,isort,mypy,doc8
skip_missing_interpreters = true

[testenv]
deps =
coverage>=5.2
freezegun
pytest>=6.0.1
ukpostcodeparser>=1.1.1
validators>=0.13.0
sphinx>=2.4,<3.0
Pillow
xmltodict
extras = test
commands =
coverage run --source=faker -m pytest {posargs}
coverage run --source=faker -a -m pytest --exclusive-faker-session tests/pytest/session_overrides {posargs}
coverage report

[testenv:flake8]
basepython = python
deps =
flake8>=4.0.0
flake8-comprehensions
extras = flake8
commands =
flake8 --extend-ignore=E203 faker tests

[testenv:checkmanifest]
basepython = python
deps =
check-manifest
extras = check-manifest
commands =
check-manifest

[testenv:isort]
deps =
isort
extras = isort
commands =
{envpython} -m isort --check-only --diff .

[testenv:mypy]
basepython = python
deps =
mypy==1.15.0
extras = mypy
commands =
mypy --install-types --non-interactive --config mypy.ini faker
{envpython} -m mypy --install-types --non-interactive --config mypy.ini faker

[testenv:black]
deps = black==24.4.0
extras = black
commands =
{envpython} -m black --check --line-length 120 .
{envpython} -m black --check .

[testenv:doc8]
deps = doc8
extras = doc8
commands =
{envpython} -m doc8

Expand Down
Loading