Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addlen to_BaseUrl to avoid TypeError#11111

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sydney-runkle merged 2 commits intopydantic:mainfromKharianne:add-len-baseurl
Dec 18, 2024

Conversation

Kharianne
Copy link
Contributor

@KharianneKharianne commentedDec 13, 2024
edited
Loading

Change Summary

Add magic method to _BaseUrl class to support allowed usage of Field with max length with AnyUrl and simple length comparison and checks of AnyUrl types.

Related issue number

fix#11092

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review,please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer:@sydney-runkle

@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelDec 13, 2024
@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedDec 13, 2024
edited
Loading

CodSpeed Performance Report

Merging#11111 willnot alter performance

ComparingKharianne:add-len-baseurl (6149769) withmain (acc5902)

Summary

✅ 46 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedDec 13, 2024
edited
Loading

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  networks.py
Project Total 

This report was generated bypython-coverage-comment-action

@Kharianne
Copy link
ContributorAuthor

please review

pydantic-hooky[bot] reacted with thumbs up emoji

Copy link
Contributor

@sydney-runklesydney-runkle left a comment

Choose a reason for hiding this comment

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

Thanks!

I think we can just tolen(self._url) in the__len__ check.

Could you also please add this fix to_BaseMultiHostUrl and add a test for that as well?

We'll get this into our patch release tomorrow :)

@pydantic-hookypydantic-hookybot added awaiting author revisionawaiting changes from the PR author and removed ready for review labelsDec 16, 2024
@Kharianne
Copy link
ContributorAuthor

Kharianne commentedDec 16, 2024
edited
Loading

@sydney-runkle

No problem! :-)
However your proposal does not work:
len(self._url) -->'pydantic_core._pydantic_core.Url' has no len()
That's why I needed to add the extra step to call the str method defined on _BaseUrl.

The self._url is a type Url from pydantic-core and this class is not of type Sized - not havinglen. Maybe this should be fixed in pydantic-core?

Edit: I added the fix to _BaseMultiHostUrl as well + test. But let me know if the fix should be here or in core.

mpkocher and sydney-runkle reacted with thumbs up emoji

@sydney-runkle
Copy link
Contributor

Hmm yeah, this makes sense I guess, we used to be able to apply directly to the core schema, and now we have this complex wrapped type.

Copy link
Contributor

@sydney-runklesydney-runkle left a comment

Choose a reason for hiding this comment

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

Thanks for the tests! Looks good for now.

We can move the__len__ support topydantic-core eventually...

@sydney-runklesydney-runkle added backport-2.10 and removed awaiting author revisionawaiting changes from the PR author labelsDec 18, 2024
@sydney-runklesydney-runkle merged commitde50a9e intopydantic:mainDec 18, 2024
103 checks passed
sydney-runkle pushed a commit that referenced this pull requestDec 18, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sydney-runklesydney-runklesydney-runkle approved these changes

Assignees

@KharianneKharianne

Labels
relnotes-fixUsed for bugfixes.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AnyUrl: TypeError: object of type 'AnyUrl' has no len()
2 participants
@Kharianne@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp