1111from configurator import Config
1212from configurator .node import ConfigNode
1313
14- from licensecheck import checker , license_matrix , packageinfo
14+ from licensecheck import checker , license_matrix
1515from licensecheck .io import fmt
1616from licensecheck .models .config import LC_Config
1717from licensecheck .models .packageinfo import PackageInfo
18+ from licensecheck .packageinforesolver import PackageInfoManager , ProjectMetadata
1819
1920stdout .reconfigure (encoding = "utf-8" ) # type: ignore[general-type-issues]
2021
@@ -117,23 +118,20 @@ def cli() -> None: # pragma: no cover
117118
118119 config : ConfigNode = Config ()
119120
120- # (Parses in the following order: `pyproject.toml`,
121- # `setup.cfg`, `licensecheck.toml`, `licensecheck.json`,
122- # `licensecheck.ini`, `~/licensecheck.toml`, `~/licensecheck.json`, `~/licensecheck.ini`)
121+ # (Parses in the following order:
123122 config_files = [
124123 "~/licensecheck.json" ,
125124 "~/licensecheck.toml" ,
126125 "licensecheck.json" ,
127126 "licensecheck.toml" ,
128- "setup.cfg" ,
129127 "pyproject.toml" ,
130128 ]
131129
132130 for file in config_files :
133131 config += Config .from_path (file , optional = True )
134132
135133 scopedData : ConfigNode = config .get ("tool" , {}).get ("licensecheck" , ConfigNode ())
136- licensecheckConf : LC_Config = LC_Config .from_mapping ( ** {** scopedData .data , ** args })
134+ licensecheckConf : LC_Config = LC_Config .model_validate ( {** scopedData .data , ** args })
137135
138136 ec = main (licensecheckConf )
139137 stdin_path .unlink (missing_ok = True )
@@ -149,17 +147,15 @@ def main(licensecheckConf: LC_Config) -> int:
149147 requirements_paths = licensecheckConf .requirements_paths or {"__stdin__" }
150148 output_file = (
151149 stdout
152- if licensecheckConf .file in [ None , "" ]
150+ if licensecheckConf .file == ""
153151 else Path (licensecheckConf .file or "" ).open ("w" , encoding = "utf-8" )
154152 )
155153
156154 # Get my license
157- this_license_text = licensecheckConf .license or packageinfo . ProjectMetadata .get_license ()
155+ this_license_text = licensecheckConf .license or ProjectMetadata .get_license ()
158156 this_license = license_matrix .licenseType (this_license_text ).pop ()
159157
160- package_info_manager = packageinfo .PackageInfoManager (
161- licensecheckConf .pypi_api or "https://pypi.org"
162- )
158+ package_info_manager = PackageInfoManager (licensecheckConf .pypi_api or "https://pypi.org" )
163159
164160 incompatible , depsWithLicenses = checker .check (
165161 requirements_paths = set (requirements_paths ),
@@ -206,6 +202,6 @@ def main(licensecheckConf: LC_Config) -> int:
206202 exitCode = 1
207203
208204 # Cleanup + exit
209- if licensecheckConf .file not in [ None , "" ] :
205+ if licensecheckConf .file != "" :
210206 output_file .close ()
211207 return exitCode
0 commit comments