Class: Dependabot::Uv::FileUpdater::PyprojectPreparer
- Inherits:
-
Object
- Object
- Dependabot::Uv::FileUpdater::PyprojectPreparer
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/uv/file_updater/pyproject_preparer.rb
Instance Method Summary collapse
-
#initialize(pyproject_content:) ⇒ PyprojectPreparer
constructor
A new instance of PyprojectPreparer.
- #sanitize ⇒ Object
- #update_python_requirement(python_version) ⇒ Object
Constructor Details
#initialize(pyproject_content:) ⇒ PyprojectPreparer
Returns a new instance of PyprojectPreparer.
21 22 23 24 |
# File 'lib/dependabot/uv/file_updater/pyproject_preparer.rb', line 21 def initialize(pyproject_content:) @pyproject_content = pyproject_content @lines = T.let(pyproject_content.split("\n"), T::Array[String]) end |
Instance Method Details
#sanitize ⇒ Object
45 46 47 48 |
# File 'lib/dependabot/uv/file_updater/pyproject_preparer.rb', line 45 def sanitize # No special sanitization needed for UV files at this point @pyproject_content end |
#update_python_requirement(python_version) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dependabot/uv/file_updater/pyproject_preparer.rb', line 27 def update_python_requirement(python_version) return @pyproject_content unless python_version in_project_table = T.let(false, T::Boolean) updated_lines = @lines.map do |line| in_project_table = true if line.match?(/^\[project\]/) if in_project_table && line.match?(/^requires-python\s*=/) "requires-python = \">=#{python_version}\"" else line end end @pyproject_content = updated_lines.join("\n") end |