Giter Club home page Giter Club logo

Comments (17)

Kludex avatar Kludex commented on June 11, 2024 3

I'm going to check. Thanks 👍

NOTE: it's a bug. I'm working on it.

from litestar.

samuelcolvin avatar samuelcolvin commented on June 11, 2024 2

Cc @Kludex.

from litestar.

JacobCoffee avatar JacobCoffee commented on June 11, 2024 1

It looks like the migration tool is available :)

https://github.com/pydantic/bump-pydantic

from litestar.

peterschutt avatar peterschutt commented on June 11, 2024

Absolutely, have you tried? How much compatibility is there b/w 1 and 2 anyway?

from litestar.

JacobCoffee avatar JacobCoffee commented on June 11, 2024

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.

JacobCoffee avatar JacobCoffee commented on June 11, 2024

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.

Goldziher avatar Goldziher commented on June 11, 2024

It looks like the migration tool is available :)

https://github.com/pydantic/bump-pydantic

this can be used for our examples and maybe tests too.

from litestar.

JacobCoffee avatar JacobCoffee commented on June 11, 2024

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 │                                                                                          │
│ ❱  75find_base_model(scratch)                                                               │
│    76 │                                                                                          │
│    77start_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:                                       │
│ ❱ 22classes = scratch[ClassDefVisitor.CONTEXT_KEY]                                          │
│   23revert_classes = revert_dictionary(classes)                                             │
│   24base_model_set: set[str] = set()                                                        │
│   25                                                                                             │
│                                                                                                  │
│ ╭─── locals ───╮                                                                                 │
│ │ scratch = {} │                                                                                 │
│ ╰──────────────╯                                                                                 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: 'class_def_visitor'

from litestar.

JacobCoffee avatar JacobCoffee commented on June 11, 2024

Without someone else confirming, though, I am too nervous to bug any of the Pydantic guys just yet.

from litestar.

JacobCoffee avatar JacobCoffee commented on June 11, 2024

In testing - specifically when i go dir-by-dir, i hit issues in the following places:

These dirs worked just fine:

  • tests/examples/
  • tests/e2e/

from litestar.

Kludex avatar Kludex commented on June 11, 2024

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 │                                                                                          │
│ ❱  75find_base_model(scratch)                                                               │
│    76 │                                                                                          │
│    77start_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:                                       │
│ ❱ 22classes = scratch[ClassDefVisitor.CONTEXT_KEY]                                          │
│   23revert_classes = revert_dictionary(classes)                                             │
│   24base_model_set: set[str] = set()                                                        │
│   25                                                                                             │
│                                                                                                  │
│ ╭─── locals ───╮                                                                                 │
│ │ scratch = {} │                                                                                 │
│ ╰──────────────╯                                                                                 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: 'class_def_visitor'

How did you run bump-pydantic?

from litestar.

JacobCoffee avatar JacobCoffee commented on June 11, 2024

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.

Kludex avatar Kludex commented on June 11, 2024

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.

provinzkraut avatar provinzkraut commented on June 11, 2024

@Kludex

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.

Kludex avatar Kludex commented on June 11, 2024

Ah, is this one: Instagram/LibCST#409

from litestar.

provinzkraut avatar provinzkraut commented on June 11, 2024

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.

Goldziher avatar Goldziher commented on June 11, 2024

This is finished on main

from litestar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.