use ruff_python_ast::{PySourceType, PythonVersion};
use crate::{AsMode, Mode};
#[derive(Clone, Debug)]
pub struct ParseOptions {
pub(crate) mode: Mode,
pub(crate) target_version: PythonVersion,
}
impl ParseOptions {
#[must_use]
pub fn with_target_version(mut self, target_version: PythonVersion) -> Self {
self.target_version = target_version;
self
}
pub fn target_version(&self) -> PythonVersion {
self.target_version
}
}
impl From<Mode> for ParseOptions {
fn from(mode: Mode) -> Self {
Self {
mode,
target_version: PythonVersion::default(),
}
}
}
impl From<PySourceType> for ParseOptions {
fn from(source_type: PySourceType) -> Self {
Self {
mode: source_type.as_mode(),
target_version: PythonVersion::default(),
}
}
}