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

core: Put Python version as a project requirement so it is considered by ruff #26608

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

cbornet
Copy link
Collaborator

@cbornet cbornet commented Sep 18, 2024

Ruff doesn't know about the python version in [tool.poetry.dependencies]. It can get it from project.requires-python.

Notes:

  • poetry seems to have issues getting the python constraints from requires-python and using python in per dependency constraints. So I had to duplicate the info. I will open an issue on poetry.
  • inspect.isclass() doesn't work correctly with GenericAlias (list[...], dict[..., ...]) on Python <3.11 so I added some not isinstance(type, GenericAlias) checks:

Python 3.11

>>> import inspect
>>> inspect.isclass(list)
True
>>> inspect.isclass(list[str])
False

Python 3.9

>>> import inspect
>>> inspect.isclass(list)
True
>>> inspect.isclass(list[str])
True

Copy link

vercel bot commented Sep 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Sep 18, 2024 2:34pm

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Ɑ: core Related to langchain-core labels Sep 18, 2024
@cbornet cbornet force-pushed the core-ruff-py39 branch 5 times, most recently from a892fb3 to 195cadd Compare September 18, 2024 11:06
@eyurtsev eyurtsev self-assigned this Sep 18, 2024
@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Sep 18, 2024
@eyurtsev eyurtsev enabled auto-merge (squash) September 18, 2024 14:37
@eyurtsev eyurtsev merged commit a47b332 into langchain-ai:master Sep 18, 2024
98 checks passed
@cbornet cbornet deleted the core-ruff-py39 branch September 18, 2024 15:12
@efriis
Copy link
Member

efriis commented Sep 18, 2024

reverting the pyproject change because core isn't installable by uv anymore as a result

I think if we completely switch metadata over to project from tool.poetry that will help, but docs build currently can't run

I think extended tests pass because none of the uv install steps actually install core - they just affect envs that have core already installed from poetry

Sheepsta300 pushed a commit to Sheepsta300/langchain that referenced this pull request Oct 1, 2024
… by ruff (langchain-ai#26608)

Ruff doesn't know about the python version in
`[tool.poetry.dependencies]`. It can get it from
`project.requires-python`.

Notes:
* poetry seems to have issues getting the python constraints from
`requires-python` and using `python` in per dependency constraints. So I
had to duplicate the info. I will open an issue on poetry.
* `inspect.isclass()` doesn't work correctly with `GenericAlias`
(`list[...]`, `dict[..., ...]`) on Python <3.11 so I added some `not
isinstance(type, GenericAlias)` checks:

Python 3.11
```pycon
>>> import inspect
>>> inspect.isclass(list)
True
>>> inspect.isclass(list[str])
False
```

Python 3.9
```pycon
>>> import inspect
>>> inspect.isclass(list)
True
>>> inspect.isclass(list[str])
True
```

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: core Related to langchain-core lgtm PR looks good. Use to confirm that a PR is ready for merging. size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants
  翻译: