Skip to content

Allow python-dateutil 3/4 and python-slugify 9, fix mypy no-any-return - #278

Open
itzzdev09 wants to merge 1 commit into
fabiocaccamo:mainfrom
itzzdev09:allow-slugify-9-and-dateutil-4
Open

itzzdev09 wants to merge 1 commit into
fabiocaccamo:mainfrom
itzzdev09:allow-slugify-9-and-dateutil-4

Conversation

@itzzdev09

Copy link
Copy Markdown

Describe your changes
The dependabot PR #276 is red on every job because of a mypy error, not because of the new versions themselves:

src/codicefiscale/codicefiscale.py:147: error: Returning Any from function declared to return "datetime | None"  [no-any-return]

mypy --install-types --non-interactive no longer pulls in types-python-dateutil, so dateutil.parser.parse() is untyped and date_obj is Any. I could reproduce it with python-dateutil 2.9.0.post0 too, as soon as the stubs aren't installed. Annotating the local (date_obj: datetime = date_parser.parse(...)) fixes it with and without the stubs, and also under mypy --strict (tox).

This PR also widens the dependency ranges in pyproject.toml:

  • python-dateutil >= 2.8, < 5.0 (was < 2.10; 3.0.0 and 4.0.0 are out)
  • python-slugify >= 7.0.0, < 10.0.0 (was < 9.0.0; 9.x keeps the legacy slug output by default)

dateutil.parser.parse with parserinfo(dayfirst/yearfirst) and slugify() behave the same in the new versions. With python-dateutil 4.0.0 + python-slugify 9.1.3 and with the current pins (2.9.0.post0 + 8.0.4), pytest tests gives 60 passed and mypy reports no issues.

The pinned requirements*.txt are left as they are, so dependabot's #276 can rebase on top of this.

Related issue
Unblocks #276.

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have added tests for the proposed changes.
  • I have run the tests and there are not errors.

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.

1 participant