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

Fix missing port in HttpUrl.build() result #3652

Merged
merged 7 commits into from May 14, 2022
Merged

Fix missing port in HttpUrl.build() result #3652

merged 7 commits into from May 14, 2022

Conversation

dolfinus
Copy link
Contributor

@dolfinus dolfinus commented Jan 10, 2022

Change Summary

Previously passing the port argument into HttpUrl.build() method has lead to including this port number to the output:

assert 'http://example.com:123' == HttpUrl.build(schema='http', host='example.com', port='123')

But a regression was introduced in #2447.

It looks like the desired behavior was to hide default port number for the protocol, but instead any port number was just being ignored.

So I've fixed a check, that only default port numbers become hidden, like 80 for http or 443 to https. Non-default port numbers are left unchanged.
Also I've added a test to cover this case.

Related issue number

No

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@dolfinus dolfinus marked this pull request as ready for review January 10, 2022 19:31
@dolfinus
Copy link
Contributor Author

please review

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

otherwise I think makes sense.

pydantic/networks.py Outdated Show resolved Hide resolved
tests/test_networks.py Show resolved Hide resolved
tests/test_networks.py Outdated Show resolved Hide resolved
pydantic/networks.py Show resolved Hide resolved
@samuelcolvin
Copy link
Member

please update.

dolfinus and others added 5 commits April 2, 2022 17:16
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
@dolfinus
Copy link
Contributor Author

dolfinus commented Apr 2, 2022

Fixed, please check

@samuelcolvin samuelcolvin mentioned this pull request May 14, 2022
11 tasks
@samuelcolvin samuelcolvin merged commit cc54acb into pydantic:master May 14, 2022
@samuelcolvin
Copy link
Member

thanks so much.

ntaylorwss pushed a commit to nicejobinc/pydantic that referenced this pull request Jun 24, 2022
* Port number is no longer being ignored by HttpUrl.build()

* Update tests/test_networks.py

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>

* Update networks.py

* Update tests/test_networks.py

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>

* Update test_networks.py

* Update test_networks.py

* update change description

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants