Skip to content

Fix is_iso_date pattern and add tests#15

Merged
pombredanne merged 3 commits intoaboutcode-org:mainfrom
ferdnyc:ferdnyc-patch-1
Jun 9, 2024
Merged

Fix is_iso_date pattern and add tests#15
pombredanne merged 3 commits intoaboutcode-org:mainfrom
ferdnyc:ferdnyc-patch-1

Conversation

@ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Jun 8, 2024

Fixes #14

Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
@ferdnyc ferdnyc force-pushed the ferdnyc-patch-1 branch from b63196f to 2dec77f Compare June 8, 2024 14:55
@pombredanne
Copy link
Member

@ferdnyc Thanks! good catch... it also means we should have a few tests for this pattern. Do you mind to add some?

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Jun 8, 2024

@pombredanne

Done. (Along with a commit to add setuptools to the testing extra's dependencies, since it's needed to run pytest.)

I've confirmed that they pass on this branch, but fail when cherry-picked into main without the fix in my 2dec77f.

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks the tests! ... just a tiny nit wrt. setuptools

setup.cfg Outdated

[options.extras_require]
testing =
setuptools >= 50
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this? We do not have any hard dependency in tests on setuptools, do we?

And FWIW, we typically use this base repo and we merge it for the boilerplate files: https://github.com/nexB/skeleton

In all cases we are progressively moving away from setuptools to use a new build tool called flot https://github.com/nexB/flot that is grown from flit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, yes. This fails with a missing setuptools:

$ python3 -m venv venv3.12
$ . ./venv3.12/bin/activate
$ pip install -e '.[testing]'
$ pytest

The build system depending on setuptools doesn't install it when not building the package, is the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pytest output without setuptools, specifically, is:

============================= test session starts ==============================
platform linux -- Python 3.12.3, pytest-8.2.2, pluggy-1.5.0
rootdir: /var/tmp/saneyaml
configfile: pyproject.toml
plugins: xdist-3.6.1
collected 24 items / 1 error                                                   

==================================== ERRORS ====================================
__________________________ ERROR collecting setup.py ___________________________
ImportError while importing test module '/var/tmp/saneyaml/setup.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
setup.py:3: in <module>
    import setuptools
E   ModuleNotFoundError: No module named 'setuptools'
=========================== short test summary info ============================
ERROR setup.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.35s ===============================

Copy link
Contributor Author

@ferdnyc ferdnyc Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably pytest shouldn't be picking up setup.py, so an exclusion in the pytest config in setup.cfg or pyproject.yaml might be an alternate way to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, I'll drop that commit, since it only affects local testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An exclusion in setup.cfg looks best indeed.

@ferdnyc ferdnyc force-pushed the ferdnyc-patch-1 branch from c5608d9 to 0c19666 Compare June 8, 2024 17:28
ferdnyc and others added 2 commits June 8, 2024 13:34
Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
These are non-valid ISO dates but we do not validate fully
just a surface validation using a regex.

This captures the weird cases we accept.

Reference: aboutcode-org#14
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>

Co-authored-by: Frank Dana <ferdnyc@gmail.com>
Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
@ferdnyc ferdnyc force-pushed the ferdnyc-patch-1 branch from 0c19666 to 3d90ec9 Compare June 8, 2024 17:34
@ferdnyc ferdnyc requested a review from pombredanne June 8, 2024 18:30
@ferdnyc ferdnyc changed the title Fix is_iso_date pattern Fix is_iso_date pattern and add tests Jun 8, 2024
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is_iso_date pattern is too liberal

2 participants