Skip to content

Commit 66ea0fc

Browse files
committed
Remove patch version number from error link
1 parent f38bea6 commit 66ea0fc

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/errors/validation_exception.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ static URL_PREFIX: GILOnceCell<String> = GILOnceCell::new();
113113

114114
fn get_url_prefix(py: Python, include_url: bool) -> Option<&str> {
115115
if include_url {
116-
Some(URL_PREFIX.get_or_init(py, || {
117-
format!(
118-
"https://errors.pydantic.dev/{}/v/",
119-
get_pydantic_version(py).unwrap_or("latest")
120-
)
121-
}))
116+
let pydantic_version = match get_pydantic_version(py) {
117+
// include major and minor version only
118+
Some(value) => value.split(".").collect::<Vec<&str>>()[..2].join("."),
119+
None => "latest".to_string(),
120+
};
121+
Some(URL_PREFIX.get_or_init(py, || format!("https://errors.pydantic.dev/{pydantic_version}/v/")))
122122
} else {
123123
None
124124
}

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ def pydantic_version():
128128
try:
129129
import pydantic
130130

131-
return pydantic.__version__
131+
# include major and minor version only
132+
return '.'.join(pydantic.__version__.split('.')[:2])
132133
except ImportError:
133134
return 'latest'
134135

0 commit comments

Comments
 (0)