Skip to content

Commit

Permalink
field is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jagonalez committed Aug 15, 2024
1 parent 3a149b2 commit 836c54b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Strategy/Python/Poetry/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import Strategy.Python.Poetry.PyProject (

-- | Gets build backend of pyproject.
getPoetryBuildBackend :: PyProject -> Maybe Text
getPoetryBuildBackend project = buildBackend <$> pyprojectBuildSystem project
getPoetryBuildBackend project = buildBackend =<< pyprojectBuildSystem project

-- | Supported pyproject dependencies.
supportedPyProjectDep :: PoetryDependency -> Bool
Expand Down
4 changes: 2 additions & 2 deletions src/Strategy/Python/Poetry/PyProject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ data PyProjectMetadata = PyProjectMetadata
deriving (Show, Eq, Ord)

newtype PyProjectBuildSystem = PyProjectBuildSystem
{ buildBackend :: Text
{ buildBackend :: Maybe Text
}
deriving (Show, Eq, Ord)

instance Toml.Schema.FromValue PyProjectBuildSystem where
fromValue =
Toml.Schema.parseTableFromValue $
PyProjectBuildSystem
<$> Toml.Schema.reqKey "build-backend"
<$> Toml.Schema.optKey "build-backend"

data PyProjectPoetry = PyProjectPoetry
{ name :: Maybe Text
Expand Down
2 changes: 1 addition & 1 deletion test/Python/Poetry/CommonSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import Toml.Schema qualified
expectedPyProject :: PyProject
expectedPyProject =
PyProject
{ pyprojectBuildSystem = Just $ PyProjectBuildSystem{buildBackend = "poetry.core.masonry.api"}
{ pyprojectBuildSystem = Just $ PyProjectBuildSystem{buildBackend = Just "poetry.core.masonry.api"}
, pyprojectProject = Nothing
, pyprojectTool =
Just $
Expand Down
4 changes: 2 additions & 2 deletions test/Python/Poetry/PyProjectSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ shouldParseInto = parseMatch parseConstraintExpr
expectedPyProject :: PyProject
expectedPyProject =
PyProject
{ pyprojectBuildSystem = Just $ PyProjectBuildSystem{buildBackend = "poetry.core.masonry.api"}
{ pyprojectBuildSystem = Just $ PyProjectBuildSystem{buildBackend = Just "poetry.core.masonry.api"}
, pyprojectProject = Nothing
, pyprojectTool =
Just $
Expand Down Expand Up @@ -90,7 +90,7 @@ expectedPyProject =
expectedPyProject3 :: PyProject
expectedPyProject3 =
PyProject
{ pyprojectBuildSystem = Just $ PyProjectBuildSystem{buildBackend = "poetry.core.masonry.api"}
{ pyprojectBuildSystem = Just $ PyProjectBuildSystem{buildBackend = Just "poetry.core.masonry.api"}
, pyprojectProject = Nothing
, pyprojectTool =
Just $
Expand Down
2 changes: 1 addition & 1 deletion test/Python/PoetrySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ newPoetryLock pkgs = PoetryLock pkgs $ PoetryMetadata "some-version" "some-hash"
candidatePyProject :: PyProject
candidatePyProject =
PyProject
{ pyprojectBuildSystem = Just $ PyProjectBuildSystem "poetry.core.masonry.api"
{ pyprojectBuildSystem = Just $ PyProjectBuildSystem{buildBackend = Just "poetry.core.masonry.api"}
, pyprojectProject = Nothing
, pyprojectTool =
Just $
Expand Down

0 comments on commit 836c54b

Please sign in to comment.