Comments (17)
I'm going to check. Thanks 👍
NOTE: it's a bug. I'm working on it.
from litestar.
Cc @Kludex.
from litestar.
It looks like the migration tool is available :)
https://github.com/pydantic/bump-pydantic
from litestar.
Absolutely, have you tried? How much compatibility is there b/w 1 and 2 anyway?
from litestar.
I have started a little branch to test things; I believe the root tests/
and other places that use polyfactory will need to be updated first or in tandem.
from litestar.
Just an update for anyone watching, the required Polyfactory changes were done in https://github.com/litestar-org/polyfactory/releases/tag/v2.3.0. I believe we can now move forward with the Litestar repo changes.
from litestar.
It looks like the migration tool is available :)
this can be used for our examples and maybe tests too.
from litestar.
I feel like i may be hitting a bug on the bump-pydantic
side, or I am doing something wrong, but it refuses to run in some dirs under test/
.
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/user/.pyenv/versions/3.11.3/lib/python3.11/site-packages/bump_pydantic/main.py:75 in │
│ main │
│ │
│ 72 │ │ │ │ for key, value in local_scratch.items(): │
│ 73 │ │ │ │ │ scratch.setdefault(key, value).update(value) │
│ 74 │ │
│ ❱ 75 │ find_base_model(scratch) │
│ 76 │ │
│ 77 │ start_time = time.time() │
│ 78 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ console = <console width=123 ColorSystem.TRUECOLOR> │ │
│ │ diff = False │ │
│ │ disable = [] │ │
│ │ files = [] │ │
│ │ files_str = [] │ │
│ │ log_file = None │ │
│ │ metadata_manager = <libcst.metadata.full_repo_manager.FullRepoManager object at │ │
│ │ 0x7faebe48e0d0> │ │
│ │ package = PosixPath('tests/logging_config') │ │
│ │ partial_visit_class_def = functools.partial(<function visit_class_def at 0x7faebde46ca0>, │ │
│ │ <libcst.metadata.full_repo_manager.FullRepoManager object at │ │
│ │ 0x7faebe48e0d0>, PosixPath('tests/logging_config')) │ │
│ │ pool = <multiprocessing.pool.Pool state=TERMINATE pool_size=24> │ │
│ │ progress = <rich.progress.Progress object at 0x7faebd9c9950> │ │
│ │ providers = { │ │
│ │ │ <class 'libcst.metadata.scope_provider.ScopeProvider'>, │ │
│ │ │ <class │ │
│ │ 'libcst.metadata.name_provider.FullyQualifiedNameProvider'> │ │
│ │ } │ │
│ │ scratch = {} │ │
│ │ task = 0 │ │
│ │ version = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/user/.pyenv/versions/3.11.3/lib/python3.11/site-packages/bump_pydantic/markers/find_bas │
│ e_model.py:22 in find_base_model │
│ │
│ 19 │
│ 20 │
│ 21 def find_base_model(scratch: dict[str, Any]) -> None: │
│ ❱ 22 │ classes = scratch[ClassDefVisitor.CONTEXT_KEY] │
│ 23 │ revert_classes = revert_dictionary(classes) │
│ 24 │ base_model_set: set[str] = set() │
│ 25 │
│ │
│ ╭─── locals ───╮ │
│ │ scratch = {} │ │
│ ╰──────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: 'class_def_visitor'
from litestar.
Without someone else confirming, though, I am too nervous to bug any of the Pydantic guys just yet.
from litestar.
In testing - specifically when i go dir-by-dir, i hit issues in the following places:
tests/logging_config/
tests/conftest.py
tests/unit/
(Gives me a very long multi-thousand line error, the bottom of which is here: https://paste.pythondiscord.com/ubezoralew)
These dirs worked just fine:
tests/examples/
tests/e2e/
from litestar.
I feel like i may be hitting a bug on the
bump-pydantic
side, or I am doing something wrong, but it refuses to run in some dirs undertest/
.╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /home/user/.pyenv/versions/3.11.3/lib/python3.11/site-packages/bump_pydantic/main.py:75 in │ │ main │ │ │ │ 72 │ │ │ │ for key, value in local_scratch.items(): │ │ 73 │ │ │ │ │ scratch.setdefault(key, value).update(value) │ │ 74 │ │ │ ❱ 75 │ find_base_model(scratch) │ │ 76 │ │ │ 77 │ start_time = time.time() │ │ 78 │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ console = <console width=123 ColorSystem.TRUECOLOR> │ │ │ │ diff = False │ │ │ │ disable = [] │ │ │ │ files = [] │ │ │ │ files_str = [] │ │ │ │ log_file = None │ │ │ │ metadata_manager = <libcst.metadata.full_repo_manager.FullRepoManager object at │ │ │ │ 0x7faebe48e0d0> │ │ │ │ package = PosixPath('tests/logging_config') │ │ │ │ partial_visit_class_def = functools.partial(<function visit_class_def at 0x7faebde46ca0>, │ │ │ │ <libcst.metadata.full_repo_manager.FullRepoManager object at │ │ │ │ 0x7faebe48e0d0>, PosixPath('tests/logging_config')) │ │ │ │ pool = <multiprocessing.pool.Pool state=TERMINATE pool_size=24> │ │ │ │ progress = <rich.progress.Progress object at 0x7faebd9c9950> │ │ │ │ providers = { │ │ │ │ │ <class 'libcst.metadata.scope_provider.ScopeProvider'>, │ │ │ │ │ <class │ │ │ │ 'libcst.metadata.name_provider.FullyQualifiedNameProvider'> │ │ │ │ } │ │ │ │ scratch = {} │ │ │ │ task = 0 │ │ │ │ version = None │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/user/.pyenv/versions/3.11.3/lib/python3.11/site-packages/bump_pydantic/markers/find_bas │ │ e_model.py:22 in find_base_model │ │ │ │ 19 │ │ 20 │ │ 21 def find_base_model(scratch: dict[str, Any]) -> None: │ │ ❱ 22 │ classes = scratch[ClassDefVisitor.CONTEXT_KEY] │ │ 23 │ revert_classes = revert_dictionary(classes) │ │ 24 │ base_model_set: set[str] = set() │ │ 25 │ │ │ │ ╭─── locals ───╮ │ │ │ scratch = {} │ │ │ ╰──────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ KeyError: 'class_def_visitor'
How did you run bump-pydantic?
from litestar.
Hi @Kludex 😃
I did this by
pip install bump-pydantic
bump-pydantic litestar/
bump-pydantic tests/ (or any of the combinations listed above e.g. `bump-pydantic tests/examples/`)
I was just blindly swinging hammers here, but I can disable rules or fix my commands.. did i miss some reading some documentation? 😬
from litestar.
It looks like LibCST cannot handle the test_converter.py
file... I'm not sure what is wrong with that file, but it fails with any visitor.
I'm modifying the bump-pydantic
in a way that it doesn't stop execution on those cases.
from litestar.
I'm not sure what is wrong with that file, but it fails with any visitor.
I have actually seen this one before. It's an issue with string literal concatenation. An otherwise empty file with ~300 lines of implicitly concatenated strings will also cause the crash.
from litestar.
Ah, is this one: Instagram/LibCST#409
from litestar.
Yeah, that one. I looked into it about a year ago but then decided it was easier to just work around it because the issue seems to be buried quite deep inside libcst 😬
@JacobCoffee We should be able to work around it by either making it two strings that are explicitly concatenated, or simply moving that stuff to a file (which would be preferable IMO).
from litestar.
This is finished on main
from litestar.
Related Issues (20)
- Bug: using Any return type on before_request handler throws an error on schema HOT 1
- Bug: schema not respecting alias generator or alias on field HOT 3
- Docs: errors in the SQLAlchemy Repository Tutorial HOT 1
- Docs: stale chart for lifecycle hooks
- Bug: CLI auto-discovery test: AssertionError: assert 'app:app' == 'app.any_name:any_name' HOT 3
- Bug: converting objects to a Bool in debug response HOT 1
- Bug: Missing API Schema for generic response type annotations HOT 2
- Enhancement: Async generated content in response body
- Enhancement: add option to make route decorators to be automatically added to the Litestar
- Enhancement: Slim down minimum required dependencies HOT 1
- Bug: `HTMXRequest` not passed to exception handlers, only gets access to standard `Request` object
- Enhancement: Allow a normal route for the "docs" (custom controller / renderer) HOT 3
- Bug: segfault when running `pytest .` with `litestar` and `ddtrace` HOT 1
- Docs: order of lifespan ctx exit and on_shutdown hooks
- Docs: Search feature improvements HOT 4
- Enhancement(CI): Add non-required CI for Python pre-releases
- Docs: Request headers missing from usage section. HOT 2
- Bug(Docs): Redirect documentation has wrong parameter
- Enhancement: Automatically document exceptions
- Enhancement: Support Pydantic 1 and 2 within the same app HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from litestar.