oci 2.138.1__py3-none-any.whl → 2.139.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. oci/_vendor/idna/__init__.py +45 -2
  2. oci/_vendor/idna/codec.py +47 -43
  3. oci/_vendor/idna/compat.py +10 -7
  4. oci/_vendor/idna/core.py +210 -173
  5. oci/_vendor/idna/idnadata.py +3869 -1676
  6. oci/_vendor/idna/intranges.py +13 -9
  7. oci/_vendor/idna/package_data.py +2 -3
  8. oci/_vendor/idna/uts46data.py +8355 -8031
  9. oci/_vendor/urllib3/__init__.py +1 -1
  10. oci/_vendor/urllib3/_collections.py +19 -1
  11. oci/_vendor/urllib3/_version.py +2 -2
  12. oci/_vendor/urllib3/connection.py +8 -3
  13. oci/_vendor/urllib3/connectionpool.py +45 -13
  14. oci/_vendor/urllib3/contrib/__init__.py +1 -1
  15. oci/_vendor/urllib3/contrib/_appengine_environ.py +1 -1
  16. oci/_vendor/urllib3/contrib/_securetransport/__init__.py +1 -1
  17. oci/_vendor/urllib3/contrib/_securetransport/bindings.py +2 -2
  18. oci/_vendor/urllib3/contrib/_securetransport/low_level.py +1 -1
  19. oci/_vendor/urllib3/contrib/appengine.py +2 -2
  20. oci/_vendor/urllib3/contrib/ntlmpool.py +3 -3
  21. oci/_vendor/urllib3/contrib/pyopenssl.py +14 -7
  22. oci/_vendor/urllib3/contrib/securetransport.py +2 -4
  23. oci/_vendor/urllib3/contrib/socks.py +1 -1
  24. oci/_vendor/urllib3/exceptions.py +1 -1
  25. oci/_vendor/urllib3/fields.py +1 -1
  26. oci/_vendor/urllib3/filepost.py +1 -1
  27. oci/_vendor/urllib3/packages/__init__.py +2 -2
  28. oci/_vendor/urllib3/packages/backports/__init__.py +1 -1
  29. oci/_vendor/urllib3/packages/backports/makefile.py +1 -1
  30. oci/_vendor/urllib3/packages/backports/weakref_finalize.py +160 -0
  31. oci/_vendor/urllib3/packages/six.py +1 -2
  32. oci/_vendor/urllib3/poolmanager.py +7 -4
  33. oci/_vendor/urllib3/request.py +22 -1
  34. oci/_vendor/urllib3/response.py +65 -4
  35. oci/_vendor/urllib3/util/__init__.py +1 -1
  36. oci/_vendor/urllib3/util/connection.py +1 -1
  37. oci/_vendor/urllib3/util/proxy.py +1 -1
  38. oci/_vendor/urllib3/util/queue.py +1 -1
  39. oci/_vendor/urllib3/util/request.py +1 -1
  40. oci/_vendor/urllib3/util/response.py +1 -1
  41. oci/_vendor/urllib3/util/retry.py +5 -3
  42. oci/_vendor/urllib3/util/ssl_.py +14 -5
  43. oci/_vendor/urllib3/util/ssl_match_hostname.py +1 -1
  44. oci/_vendor/urllib3/util/ssltransport.py +1 -1
  45. oci/_vendor/urllib3/util/timeout.py +7 -4
  46. oci/_vendor/urllib3/util/url.py +8 -5
  47. oci/_vendor/urllib3/util/wait.py +1 -2
  48. oci/access_governance_cp/access_governance_cp_client.py +8 -8
  49. oci/adm/application_dependency_management_client.py +36 -36
  50. oci/ai_anomaly_detection/anomaly_detection_client.py +36 -36
  51. oci/ai_document/ai_service_document_client.py +26 -26
  52. oci/ai_language/ai_service_language_client.py +44 -44
  53. oci/ai_speech/ai_service_speech_client.py +19 -19
  54. oci/ai_vision/ai_service_vision_client.py +25 -25
  55. oci/analytics/analytics_client.py +24 -24
  56. oci/announcements_service/announcement_client.py +5 -5
  57. oci/announcements_service/announcement_subscription_client.py +9 -9
  58. oci/announcements_service/announcements_preferences_client.py +4 -4
  59. oci/announcements_service/service_client.py +1 -1
  60. oci/apigateway/api_gateway_client.py +21 -21
  61. oci/apigateway/deployment_client.py +6 -6
  62. oci/apigateway/gateway_client.py +6 -6
  63. oci/apigateway/subscribers_client.py +6 -6
  64. oci/apigateway/usage_plans_client.py +6 -6
  65. oci/apigateway/work_requests_client.py +5 -5
  66. oci/apm_config/config_client.py +9 -9
  67. oci/apm_control_plane/apm_domain_client.py +14 -14
  68. oci/apm_synthetics/apm_synthetic_client.py +28 -28
  69. oci/apm_traces/attributes_client.py +8 -8
  70. oci/apm_traces/query_client.py +2 -2
  71. oci/apm_traces/trace_client.py +4 -4
  72. oci/appmgmt_control/appmgmt_control_client.py +8 -8
  73. oci/artifacts/artifacts_client.py +32 -32
  74. oci/audit/audit_client.py +3 -3
  75. oci/autoscaling/auto_scaling_client.py +11 -11
  76. oci/bastion/bastion_client.py +15 -15
  77. oci/bds/bds_client.py +72 -72
  78. oci/blockchain/blockchain_platform_client.py +27 -27
  79. oci/budget/budget_client.py +10 -10
  80. oci/capacity_management/capacity_management_client.py +32 -32
  81. oci/certificates/certificates_client.py +5 -5
  82. oci/certificates_management/certificates_management_client.py +32 -32
  83. oci/cims/incident_client.py +13 -14
  84. oci/cims/models/__init__.py +4 -2
  85. oci/cims/models/cmos_user_group_info.py +103 -0
  86. oci/cims/models/create_incident.py +33 -2
  87. oci/cims/models/create_limit_item_details.py +2 -57
  88. oci/cims/models/create_user_details.py +4 -4
  89. oci/cims/models/incident.py +188 -0
  90. oci/cims/models/incident_resource_type.py +4 -4
  91. oci/cims/models/incident_summary.py +188 -0
  92. oci/cims/models/limit_item.py +2 -2
  93. oci/cims/models/{service_categories.py → services.py} +27 -27
  94. oci/cims/models/sub_categories.py +15 -15
  95. oci/cims/models/ticket.py +7 -3
  96. oci/cims/models/validation_response.py +33 -2
  97. oci/cloud_bridge/common_client.py +5 -5
  98. oci/cloud_bridge/discovery_client.py +15 -15
  99. oci/cloud_bridge/inventory_client.py +16 -16
  100. oci/cloud_bridge/ocb_agent_svc_client.py +22 -22
  101. oci/cloud_guard/cloud_guard_client.py +155 -155
  102. oci/cloud_migrations/migration_client.py +43 -43
  103. oci/cluster_placement_groups/cluster_placement_groups_cp_client.py +13 -13
  104. oci/compute_cloud_at_customer/compute_cloud_at_customer_client.py +12 -12
  105. oci/compute_instance_agent/compute_instance_agent_client.py +6 -6
  106. oci/compute_instance_agent/plugin_client.py +2 -2
  107. oci/compute_instance_agent/pluginconfig_client.py +1 -1
  108. oci/container_engine/container_engine_client.py +44 -44
  109. oci/container_instances/container_instance_client.py +18 -18
  110. oci/core/blockstorage_client.py +60 -60
  111. oci/core/compute_client.py +102 -102
  112. oci/core/compute_management_client.py +32 -32
  113. oci/core/virtual_network_client.py +247 -247
  114. oci/dashboard_service/dashboard_client.py +6 -6
  115. oci/dashboard_service/dashboard_group_client.py +6 -6
  116. oci/data_catalog/data_catalog_client.py +149 -149
  117. oci/data_flow/data_flow_client.py +44 -44
  118. oci/data_integration/data_integration_client.py +163 -163
  119. oci/data_labeling_service/data_labeling_management_client.py +17 -17
  120. oci/data_labeling_service_dataplane/data_labeling_client.py +15 -15
  121. oci/data_safe/data_safe_client.py +292 -292
  122. oci/data_science/data_science_client.py +92 -92
  123. oci/database/database_client.py +523 -398
  124. oci/database/database_client_composite_operations.py +88 -0
  125. oci/database/models/__init__.py +4 -0
  126. oci/database/models/autonomous_database.py +2 -2
  127. oci/database/models/autonomous_database_summary.py +2 -2
  128. oci/database/models/configure_exascale_exadata_infrastructure_details.py +72 -0
  129. oci/database/models/create_autonomous_database_base.py +2 -2
  130. oci/database/models/create_db_home_details.py +33 -2
  131. oci/database/models/create_db_home_from_backup_details.py +31 -0
  132. oci/database/models/create_db_home_from_database_details.py +31 -0
  133. oci/database/models/create_exascale_db_storage_vault_details.py +37 -2
  134. oci/database/models/create_pluggable_database_creation_type_details.py +2 -2
  135. oci/database/models/create_vm_cluster_details.py +37 -2
  136. oci/database/models/exadata_infrastructure.py +29 -2
  137. oci/database/models/exadata_infrastructure_summary.py +29 -2
  138. oci/database/models/exascale_config_details.py +103 -0
  139. oci/database/models/exascale_db_storage_vault.py +35 -0
  140. oci/database/models/exascale_db_storage_vault_summary.py +37 -2
  141. oci/database/models/update_autonomous_database_details.py +2 -2
  142. oci/database/models/vm_cluster.py +84 -2
  143. oci/database/models/vm_cluster_summary.py +84 -2
  144. oci/database_management/db_management_client.py +211 -211
  145. oci/database_management/diagnosability_client.py +4 -4
  146. oci/database_management/managed_my_sql_databases_client.py +7 -7
  147. oci/database_management/perfhub_client.py +1 -1
  148. oci/database_management/sql_tuning_client.py +17 -17
  149. oci/database_migration/database_migration_client.py +42 -42
  150. oci/database_tools/database_tools_client.py +23 -23
  151. oci/delegate_access_control/delegate_access_control_client.py +26 -26
  152. oci/delegate_access_control/work_request_client.py +4 -4
  153. oci/demand_signal/occ_demand_signal_client.py +7 -7
  154. oci/desktops/desktop_service_client.py +21 -21
  155. oci/devops/devops_client.py +141 -141
  156. oci/disaster_recovery/disaster_recovery_client.py +29 -29
  157. oci/dns/dns_client.py +54 -54
  158. oci/dts/appliance_export_job_client.py +6 -6
  159. oci/dts/shipping_vendors_client.py +1 -1
  160. oci/dts/transfer_appliance_client.py +8 -8
  161. oci/dts/transfer_appliance_entitlement_client.py +3 -3
  162. oci/dts/transfer_device_client.py +5 -5
  163. oci/dts/transfer_job_client.py +6 -6
  164. oci/dts/transfer_package_client.py +7 -7
  165. oci/em_warehouse/em_warehouse_client.py +13 -13
  166. oci/email/email_client.py +31 -31
  167. oci/email_data_plane/email_dp_client.py +1 -1
  168. oci/events/events_client.py +6 -6
  169. oci/file_storage/file_storage_client.py +68 -68
  170. oci/fleet_apps_management/fleet_apps_management_admin_client.py +25 -25
  171. oci/fleet_apps_management/fleet_apps_management_client.py +35 -35
  172. oci/fleet_apps_management/fleet_apps_management_maintenance_window_client.py +5 -5
  173. oci/fleet_apps_management/fleet_apps_management_operations_client.py +26 -26
  174. oci/fleet_apps_management/fleet_apps_management_runbooks_client.py +12 -12
  175. oci/fleet_software_update/fleet_software_update_client.py +46 -46
  176. oci/functions/functions_invoke_client.py +1 -1
  177. oci/functions/functions_management_client.py +16 -16
  178. oci/fusion_apps/fusion_applications_client.py +41 -41
  179. oci/generative_ai/generative_ai_client.py +22 -22
  180. oci/generative_ai_agent/generative_ai_agent_client.py +33 -33
  181. oci/generative_ai_agent_runtime/generative_ai_agent_runtime_client.py +5 -5
  182. oci/generative_ai_inference/generative_ai_inference_client.py +4 -4
  183. oci/generic_artifacts_content/generic_artifacts_content_client.py +3 -3
  184. oci/globally_distributed_database/sharded_database_service_client.py +30 -30
  185. oci/golden_gate/golden_gate_client.py +70 -70
  186. oci/governance_rules_control_plane/governance_rule_client.py +15 -15
  187. oci/governance_rules_control_plane/work_request_client.py +5 -5
  188. oci/healthchecks/health_checks_client.py +17 -17
  189. oci/identity/identity_client.py +145 -145
  190. oci/identity_data_plane/dataplane_client.py +2 -2
  191. oci/identity_domains/identity_domains_client.py +311 -311
  192. oci/integration/integration_instance_client.py +19 -19
  193. oci/jms/java_management_service_client.py +75 -75
  194. oci/jms_java_downloads/java_download_client.py +25 -25
  195. oci/key_management/ekm_client.py +5 -5
  196. oci/key_management/kms_crypto_client.py +6 -6
  197. oci/key_management/kms_hsm_cluster_client.py +12 -12
  198. oci/key_management/kms_management_client.py +21 -21
  199. oci/key_management/kms_vault_client.py +14 -14
  200. oci/license_manager/license_manager_client.py +18 -18
  201. oci/limits/limits_client.py +4 -4
  202. oci/limits/quotas_client.py +7 -7
  203. oci/load_balancer/load_balancer_client.py +61 -61
  204. oci/lockbox/lockbox_client.py +24 -24
  205. oci/log_analytics/log_analytics_client.py +193 -193
  206. oci/logging/logging_management_client.py +30 -30
  207. oci/loggingingestion/logging_client.py +1 -1
  208. oci/loggingsearch/log_search_client.py +1 -1
  209. oci/management_agent/management_agent_client.py +28 -28
  210. oci/management_dashboard/dashx_apis_client.py +14 -14
  211. oci/marketplace/account_client.py +2 -2
  212. oci/marketplace/marketplace_client.py +30 -30
  213. oci/marketplace_private_offer/attachment_client.py +5 -5
  214. oci/marketplace_private_offer/offer_client.py +6 -6
  215. oci/marketplace_publisher/attachment_client.py +5 -5
  216. oci/marketplace_publisher/marketplace_publisher_client.py +71 -71
  217. oci/marketplace_publisher/offer_client.py +6 -6
  218. oci/media_services/media_services_client.py +60 -60
  219. oci/media_services/media_stream_client.py +2 -2
  220. oci/monitoring/monitoring_client.py +18 -18
  221. oci/mysql/channels_client.py +7 -7
  222. oci/mysql/db_backups_client.py +7 -7
  223. oci/mysql/db_system_client.py +17 -17
  224. oci/mysql/mysqlaas_client.py +7 -7
  225. oci/mysql/replicas_client.py +5 -5
  226. oci/mysql/work_requests_client.py +4 -4
  227. oci/network_firewall/network_firewall_client.py +86 -86
  228. oci/network_load_balancer/network_load_balancer_client.py +34 -34
  229. oci/nosql/nosql_client.py +24 -24
  230. oci/object_storage/object_storage_client.py +153 -57
  231. oci/oce/oce_instance_client.py +10 -10
  232. oci/oci_control_center/occ_metrics_client.py +3 -3
  233. oci/ocvp/cluster_client.py +5 -5
  234. oci/ocvp/esxi_host_client.py +8 -8
  235. oci/ocvp/sddc_client.py +14 -14
  236. oci/ocvp/work_request_client.py +4 -4
  237. oci/oda/management_client.py +59 -59
  238. oci/oda/oda_client.py +17 -17
  239. oci/oda/odapackage_client.py +7 -7
  240. oci/onesubscription/billing_schedule_client.py +1 -1
  241. oci/onesubscription/commitment_client.py +2 -2
  242. oci/onesubscription/computed_usage_client.py +3 -3
  243. oci/onesubscription/invoice_summary_client.py +2 -2
  244. oci/onesubscription/organization_subscription_client.py +1 -1
  245. oci/onesubscription/ratecard_client.py +1 -1
  246. oci/onesubscription/subscribed_service_client.py +2 -2
  247. oci/onesubscription/subscription_client.py +1 -1
  248. oci/ons/notification_control_plane_client.py +6 -6
  249. oci/ons/notification_data_plane_client.py +10 -10
  250. oci/opa/opa_instance_client.py +13 -13
  251. oci/opensearch/opensearch_cluster_backup_client.py +4 -4
  252. oci/opensearch/opensearch_cluster_client.py +14 -14
  253. oci/operator_access_control/access_requests_client.py +10 -10
  254. oci/operator_access_control/operator_actions_client.py +2 -2
  255. oci/operator_access_control/operator_control_assignment_client.py +8 -8
  256. oci/operator_access_control/operator_control_client.py +6 -6
  257. oci/opsi/operations_insights_client.py +180 -180
  258. oci/optimizer/optimizer_client.py +26 -26
  259. oci/os_management/event_client.py +8 -8
  260. oci/os_management/os_management_client.py +69 -69
  261. oci/os_management_hub/event_client.py +8 -8
  262. oci/os_management_hub/lifecycle_environment_client.py +12 -12
  263. oci/os_management_hub/managed_instance_client.py +31 -31
  264. oci/os_management_hub/managed_instance_group_client.py +25 -25
  265. oci/os_management_hub/management_station_client.py +10 -10
  266. oci/os_management_hub/onboarding_client.py +6 -6
  267. oci/os_management_hub/reporting_managed_instance_client.py +3 -3
  268. oci/os_management_hub/scheduled_job_client.py +7 -7
  269. oci/os_management_hub/software_source_client.py +27 -27
  270. oci/os_management_hub/work_request_client.py +4 -4
  271. oci/osp_gateway/address_rule_service_client.py +1 -1
  272. oci/osp_gateway/address_service_client.py +2 -2
  273. oci/osp_gateway/invoice_service_client.py +5 -5
  274. oci/osp_gateway/subscription_service_client.py +5 -5
  275. oci/osub_billing_schedule/billing_schedule_client.py +1 -1
  276. oci/osub_organization_subscription/organization_subscription_client.py +1 -1
  277. oci/osub_subscription/commitment_client.py +2 -2
  278. oci/osub_subscription/ratecard_client.py +1 -1
  279. oci/osub_subscription/subscription_client.py +1 -1
  280. oci/osub_usage/computed_usage_client.py +3 -3
  281. oci/psql/models/connection_details.py +29 -2
  282. oci/psql/models/endpoint.py +1 -1
  283. oci/psql/models/network_details.py +33 -2
  284. oci/psql/models/update_network_details.py +33 -2
  285. oci/psql/postgresql_client.py +33 -33
  286. oci/queue/queue_admin_client.py +11 -11
  287. oci/queue/queue_client.py +8 -8
  288. oci/recovery/database_recovery_client.py +26 -26
  289. oci/redis/redis_cluster_client.py +12 -12
  290. oci/resource_manager/resource_manager_client.py +52 -52
  291. oci/resource_scheduler/schedule_client.py +13 -13
  292. oci/resource_search/resource_search_client.py +3 -3
  293. oci/rover/rover_bundle_client.py +8 -8
  294. oci/rover/rover_cluster_client.py +8 -8
  295. oci/rover/rover_entitlement_client.py +6 -6
  296. oci/rover/rover_node_client.py +15 -15
  297. oci/rover/shape_client.py +1 -1
  298. oci/rover/work_requests_client.py +5 -5
  299. oci/sch/connector_plugins_client.py +2 -2
  300. oci/sch/service_connector_client.py +12 -12
  301. oci/secrets/secrets_client.py +3 -3
  302. oci/security_attribute/security_attribute_client.py +18 -18
  303. oci/service_catalog/service_catalog_client.py +26 -26
  304. oci/service_manager_proxy/service_manager_proxy_client.py +2 -2
  305. oci/service_mesh/service_mesh_client.py +48 -48
  306. oci/stack_monitoring/stack_monitoring_client.py +71 -71
  307. oci/streaming/stream_admin_client.py +18 -18
  308. oci/streaming/stream_client.py +8 -8
  309. oci/tenant_manager_control_plane/domain_client.py +5 -5
  310. oci/tenant_manager_control_plane/domain_governance_client.py +5 -5
  311. oci/tenant_manager_control_plane/governance_client.py +2 -2
  312. oci/tenant_manager_control_plane/link_client.py +3 -3
  313. oci/tenant_manager_control_plane/orders_client.py +2 -2
  314. oci/tenant_manager_control_plane/organization_client.py +10 -10
  315. oci/tenant_manager_control_plane/recipient_invitation_client.py +5 -5
  316. oci/tenant_manager_control_plane/sender_invitation_client.py +5 -5
  317. oci/tenant_manager_control_plane/subscription_client.py +11 -11
  318. oci/tenant_manager_control_plane/work_request_client.py +4 -4
  319. oci/threat_intelligence/threatintel_client.py +5 -5
  320. oci/usage/resources_client.py +2 -2
  321. oci/usage/rewards_client.py +6 -6
  322. oci/usage/usagelimits_client.py +1 -1
  323. oci/usage_api/usageapi_client.py +33 -33
  324. oci/vault/vaults_client.py +13 -13
  325. oci/vbs_inst/vbs_instance_client.py +10 -10
  326. oci/version.py +1 -1
  327. oci/visual_builder/vb_instance_client.py +13 -13
  328. oci/vn_monitoring/vn_monitoring_client.py +12 -12
  329. oci/vulnerability_scanning/vulnerability_scanning_client.py +58 -58
  330. oci/waa/waa_client.py +13 -13
  331. oci/waa/work_request_client.py +4 -4
  332. oci/waas/redirect_client.py +6 -6
  333. oci/waas/waas_client.py +66 -66
  334. oci/waf/waf_client.py +24 -24
  335. oci/work_requests/work_request_client.py +4 -4
  336. oci/zpr/zpr_client.py +15 -15
  337. {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/METADATA +1 -1
  338. {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/RECORD +342 -338
  339. {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/THIRD_PARTY_LICENSES.txt +1 -1
  340. {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/LICENSE.txt +0 -0
  341. {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/WHEEL +0 -0
  342. {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/top_level.txt +0 -0
oci/_vendor/idna/core.py CHANGED
@@ -1,366 +1,396 @@
1
1
  # coding: utf-8
2
2
  # Modified Work: Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
3
3
  # This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
4
- # Copyright (c) 2013-2018, Kim Davies. All rights reserved.
4
+ # Copyright (c) 2013-2024, Kim Davies and contributors. All rights reserved.
5
5
 
6
- from . import idnadata
7
6
  import bisect
8
- import unicodedata
9
7
  import re
10
- import sys
8
+ import unicodedata
9
+ from typing import Optional, Union
10
+
11
+ from . import idnadata
11
12
  from .intranges import intranges_contain
12
13
 
13
14
  _virama_combining_class = 9
14
- _alabel_prefix = b'xn--'
15
- _unicode_dots_re = re.compile(u'[\u002e\u3002\uff0e\uff61]')
15
+ _alabel_prefix = b"xn--"
16
+ _unicode_dots_re = re.compile("[\u002e\u3002\uff0e\uff61]")
16
17
 
17
- if sys.version_info[0] >= 3:
18
- unicode = str
19
- unichr = chr
20
18
 
21
19
  class IDNAError(UnicodeError):
22
- """ Base exception for all IDNA-encoding related problems """
20
+ """Base exception for all IDNA-encoding related problems"""
21
+
23
22
  pass
24
23
 
25
24
 
26
25
  class IDNABidiError(IDNAError):
27
- """ Exception when bidirectional requirements are not satisfied """
26
+ """Exception when bidirectional requirements are not satisfied"""
27
+
28
28
  pass
29
29
 
30
30
 
31
31
  class InvalidCodepoint(IDNAError):
32
- """ Exception when a disallowed or unallocated codepoint is used """
32
+ """Exception when a disallowed or unallocated codepoint is used"""
33
+
33
34
  pass
34
35
 
35
36
 
36
37
  class InvalidCodepointContext(IDNAError):
37
- """ Exception when the codepoint is not valid in the context it is used """
38
+ """Exception when the codepoint is not valid in the context it is used"""
39
+
38
40
  pass
39
41
 
40
42
 
41
- def _combining_class(cp):
42
- v = unicodedata.combining(unichr(cp))
43
+ def _combining_class(cp: int) -> int:
44
+ v = unicodedata.combining(chr(cp))
43
45
  if v == 0:
44
- if not unicodedata.name(unichr(cp)):
46
+ if not unicodedata.name(chr(cp)):
45
47
  raise ValueError("Unknown character in unicodedata")
46
48
  return v
47
49
 
48
- def _is_script(cp, script):
50
+
51
+ def _is_script(cp: str, script: str) -> bool:
49
52
  return intranges_contain(ord(cp), idnadata.scripts[script])
50
53
 
51
- def _punycode(s):
52
- return s.encode('punycode')
53
54
 
54
- def _unot(s):
55
- return 'U+{0:04X}'.format(s)
55
+ def _punycode(s: str) -> bytes:
56
+ return s.encode("punycode")
56
57
 
57
58
 
58
- def valid_label_length(label):
59
+ def _unot(s: int) -> str:
60
+ return "U+{:04X}".format(s)
59
61
 
62
+
63
+ def valid_label_length(label: Union[bytes, str]) -> bool:
60
64
  if len(label) > 63:
61
65
  return False
62
66
  return True
63
67
 
64
68
 
65
- def valid_string_length(label, trailing_dot):
66
-
69
+ def valid_string_length(label: Union[bytes, str], trailing_dot: bool) -> bool:
67
70
  if len(label) > (254 if trailing_dot else 253):
68
71
  return False
69
72
  return True
70
73
 
71
74
 
72
- def check_bidi(label, check_ltr=False):
73
-
75
+ def check_bidi(label: str, check_ltr: bool = False) -> bool:
74
76
  # Bidi rules should only be applied if string contains RTL characters
75
77
  bidi_label = False
76
- for (idx, cp) in enumerate(label, 1):
78
+ for idx, cp in enumerate(label, 1):
77
79
  direction = unicodedata.bidirectional(cp)
78
- if direction == '':
80
+ if direction == "":
79
81
  # String likely comes from a newer version of Unicode
80
- raise IDNABidiError('Unknown directionality in label {0} at position {1}'.format(repr(label), idx))
81
- if direction in ['R', 'AL', 'AN']:
82
+ raise IDNABidiError("Unknown directionality in label {} at position {}".format(repr(label), idx))
83
+ if direction in ["R", "AL", "AN"]:
82
84
  bidi_label = True
83
85
  if not bidi_label and not check_ltr:
84
86
  return True
85
87
 
86
88
  # Bidi rule 1
87
89
  direction = unicodedata.bidirectional(label[0])
88
- if direction in ['R', 'AL']:
90
+ if direction in ["R", "AL"]:
89
91
  rtl = True
90
- elif direction == 'L':
92
+ elif direction == "L":
91
93
  rtl = False
92
94
  else:
93
- raise IDNABidiError('First codepoint in label {0} must be directionality L, R or AL'.format(repr(label)))
95
+ raise IDNABidiError("First codepoint in label {} must be directionality L, R or AL".format(repr(label)))
94
96
 
95
97
  valid_ending = False
96
- number_type = False
97
- for (idx, cp) in enumerate(label, 1):
98
+ number_type: Optional[str] = None
99
+ for idx, cp in enumerate(label, 1):
98
100
  direction = unicodedata.bidirectional(cp)
99
101
 
100
102
  if rtl:
101
103
  # Bidi rule 2
102
- if not direction in ['R', 'AL', 'AN', 'EN', 'ES', 'CS', 'ET', 'ON', 'BN', 'NSM']:
103
- raise IDNABidiError('Invalid direction for codepoint at position {0} in a right-to-left label'.format(idx))
104
+ if direction not in [
105
+ "R",
106
+ "AL",
107
+ "AN",
108
+ "EN",
109
+ "ES",
110
+ "CS",
111
+ "ET",
112
+ "ON",
113
+ "BN",
114
+ "NSM",
115
+ ]:
116
+ raise IDNABidiError("Invalid direction for codepoint at position {} in a right-to-left label".format(idx))
104
117
  # Bidi rule 3
105
- if direction in ['R', 'AL', 'EN', 'AN']:
118
+ if direction in ["R", "AL", "EN", "AN"]:
106
119
  valid_ending = True
107
- elif direction != 'NSM':
120
+ elif direction != "NSM":
108
121
  valid_ending = False
109
122
  # Bidi rule 4
110
- if direction in ['AN', 'EN']:
123
+ if direction in ["AN", "EN"]:
111
124
  if not number_type:
112
125
  number_type = direction
113
126
  else:
114
127
  if number_type != direction:
115
- raise IDNABidiError('Can not mix numeral types in a right-to-left label')
128
+ raise IDNABidiError("Can not mix numeral types in a right-to-left label")
116
129
  else:
117
130
  # Bidi rule 5
118
- if not direction in ['L', 'EN', 'ES', 'CS', 'ET', 'ON', 'BN', 'NSM']:
119
- raise IDNABidiError('Invalid direction for codepoint at position {0} in a left-to-right label'.format(idx))
131
+ if direction not in ["L", "EN", "ES", "CS", "ET", "ON", "BN", "NSM"]:
132
+ raise IDNABidiError("Invalid direction for codepoint at position {} in a left-to-right label".format(idx))
120
133
  # Bidi rule 6
121
- if direction in ['L', 'EN']:
134
+ if direction in ["L", "EN"]:
122
135
  valid_ending = True
123
- elif direction != 'NSM':
136
+ elif direction != "NSM":
124
137
  valid_ending = False
125
138
 
126
139
  if not valid_ending:
127
- raise IDNABidiError('Label ends with illegal codepoint directionality')
140
+ raise IDNABidiError("Label ends with illegal codepoint directionality")
128
141
 
129
142
  return True
130
143
 
131
144
 
132
- def check_initial_combiner(label):
133
-
134
- if unicodedata.category(label[0])[0] == 'M':
135
- raise IDNAError('Label begins with an illegal combining character')
145
+ def check_initial_combiner(label: str) -> bool:
146
+ if unicodedata.category(label[0])[0] == "M":
147
+ raise IDNAError("Label begins with an illegal combining character")
136
148
  return True
137
149
 
138
150
 
139
- def check_hyphen_ok(label):
140
-
141
- if label[2:4] == '--':
142
- raise IDNAError('Label has disallowed hyphens in 3rd and 4th position')
143
- if label[0] == '-' or label[-1] == '-':
144
- raise IDNAError('Label must not start or end with a hyphen')
151
+ def check_hyphen_ok(label: str) -> bool:
152
+ if label[2:4] == "--":
153
+ raise IDNAError("Label has disallowed hyphens in 3rd and 4th position")
154
+ if label[0] == "-" or label[-1] == "-":
155
+ raise IDNAError("Label must not start or end with a hyphen")
145
156
  return True
146
157
 
147
158
 
148
- def check_nfc(label):
159
+ def check_nfc(label: str) -> None:
160
+ if unicodedata.normalize("NFC", label) != label:
161
+ raise IDNAError("Label must be in Normalization Form C")
149
162
 
150
- if unicodedata.normalize('NFC', label) != label:
151
- raise IDNAError('Label must be in Normalization Form C')
152
-
153
-
154
- def valid_contextj(label, pos):
155
163
 
164
+ def valid_contextj(label: str, pos: int) -> bool:
156
165
  cp_value = ord(label[pos])
157
166
 
158
- if cp_value == 0x200c:
159
-
167
+ if cp_value == 0x200C:
160
168
  if pos > 0:
161
169
  if _combining_class(ord(label[pos - 1])) == _virama_combining_class:
162
170
  return True
163
171
 
164
172
  ok = False
165
- for i in range(pos-1, -1, -1):
173
+ for i in range(pos - 1, -1, -1):
166
174
  joining_type = idnadata.joining_types.get(ord(label[i]))
167
- if joining_type == ord('T'):
175
+ if joining_type == ord("T"):
168
176
  continue
169
- if joining_type in [ord('L'), ord('D')]:
177
+ elif joining_type in [ord("L"), ord("D")]:
170
178
  ok = True
171
179
  break
180
+ else:
181
+ break
172
182
 
173
183
  if not ok:
174
184
  return False
175
185
 
176
186
  ok = False
177
- for i in range(pos+1, len(label)):
187
+ for i in range(pos + 1, len(label)):
178
188
  joining_type = idnadata.joining_types.get(ord(label[i]))
179
- if joining_type == ord('T'):
189
+ if joining_type == ord("T"):
180
190
  continue
181
- if joining_type in [ord('R'), ord('D')]:
191
+ elif joining_type in [ord("R"), ord("D")]:
182
192
  ok = True
183
193
  break
194
+ else:
195
+ break
184
196
  return ok
185
197
 
186
- if cp_value == 0x200d:
187
-
198
+ if cp_value == 0x200D:
188
199
  if pos > 0:
189
200
  if _combining_class(ord(label[pos - 1])) == _virama_combining_class:
190
201
  return True
191
202
  return False
192
203
 
193
204
  else:
194
-
195
205
  return False
196
206
 
197
207
 
198
- def valid_contexto(label, pos, exception=False):
199
-
208
+ def valid_contexto(label: str, pos: int, exception: bool = False) -> bool:
200
209
  cp_value = ord(label[pos])
201
210
 
202
- if cp_value == 0x00b7:
203
- if 0 < pos < len(label)-1:
204
- if ord(label[pos - 1]) == 0x006c and ord(label[pos + 1]) == 0x006c:
211
+ if cp_value == 0x00B7:
212
+ if 0 < pos < len(label) - 1:
213
+ if ord(label[pos - 1]) == 0x006C and ord(label[pos + 1]) == 0x006C:
205
214
  return True
206
215
  return False
207
216
 
208
217
  elif cp_value == 0x0375:
209
- if pos < len(label)-1 and len(label) > 1:
210
- return _is_script(label[pos + 1], 'Greek')
218
+ if pos < len(label) - 1 and len(label) > 1:
219
+ return _is_script(label[pos + 1], "Greek")
211
220
  return False
212
221
 
213
- elif cp_value == 0x05f3 or cp_value == 0x05f4:
222
+ elif cp_value == 0x05F3 or cp_value == 0x05F4:
214
223
  if pos > 0:
215
- return _is_script(label[pos - 1], 'Hebrew')
224
+ return _is_script(label[pos - 1], "Hebrew")
216
225
  return False
217
226
 
218
- elif cp_value == 0x30fb:
227
+ elif cp_value == 0x30FB:
219
228
  for cp in label:
220
- if cp == u'\u30fb':
229
+ if cp == "\u30fb":
221
230
  continue
222
- if _is_script(cp, 'Hiragana') or _is_script(cp, 'Katakana') or _is_script(cp, 'Han'):
231
+ if _is_script(cp, "Hiragana") or _is_script(cp, "Katakana") or _is_script(cp, "Han"):
223
232
  return True
224
233
  return False
225
234
 
226
235
  elif 0x660 <= cp_value <= 0x669:
227
236
  for cp in label:
228
- if 0x6f0 <= ord(cp) <= 0x06f9:
237
+ if 0x6F0 <= ord(cp) <= 0x06F9:
229
238
  return False
230
239
  return True
231
240
 
232
- elif 0x6f0 <= cp_value <= 0x6f9:
241
+ elif 0x6F0 <= cp_value <= 0x6F9:
233
242
  for cp in label:
234
243
  if 0x660 <= ord(cp) <= 0x0669:
235
244
  return False
236
245
  return True
237
246
 
247
+ return False
238
248
 
239
- def check_label(label):
240
249
 
250
+ def check_label(label: Union[str, bytes, bytearray]) -> None:
241
251
  if isinstance(label, (bytes, bytearray)):
242
- label = label.decode('utf-8')
252
+ label = label.decode("utf-8")
243
253
  if len(label) == 0:
244
- raise IDNAError('Empty Label')
254
+ raise IDNAError("Empty Label")
245
255
 
246
256
  check_nfc(label)
247
257
  check_hyphen_ok(label)
248
258
  check_initial_combiner(label)
249
259
 
250
- for (pos, cp) in enumerate(label):
260
+ for pos, cp in enumerate(label):
251
261
  cp_value = ord(cp)
252
- if intranges_contain(cp_value, idnadata.codepoint_classes['PVALID']):
262
+ if intranges_contain(cp_value, idnadata.codepoint_classes["PVALID"]):
253
263
  continue
254
- elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTJ']):
264
+ elif intranges_contain(cp_value, idnadata.codepoint_classes["CONTEXTJ"]):
255
265
  try:
256
266
  if not valid_contextj(label, pos):
257
- raise InvalidCodepointContext('Joiner {0} not allowed at position {1} in {2}'.format(
258
- _unot(cp_value), pos+1, repr(label)))
267
+ raise InvalidCodepointContext(
268
+ "Joiner {} not allowed at position {} in {}".format(_unot(cp_value), pos + 1, repr(label))
269
+ )
259
270
  except ValueError:
260
- raise IDNAError('Unknown codepoint adjacent to joiner {0} at position {1} in {2}'.format(
261
- _unot(cp_value), pos+1, repr(label)))
262
- elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTO']):
271
+ raise IDNAError(
272
+ "Unknown codepoint adjacent to joiner {} at position {} in {}".format(
273
+ _unot(cp_value), pos + 1, repr(label)
274
+ )
275
+ )
276
+ elif intranges_contain(cp_value, idnadata.codepoint_classes["CONTEXTO"]):
263
277
  if not valid_contexto(label, pos):
264
- raise InvalidCodepointContext('Codepoint {0} not allowed at position {1} in {2}'.format(_unot(cp_value), pos+1, repr(label)))
278
+ raise InvalidCodepointContext(
279
+ "Codepoint {} not allowed at position {} in {}".format(_unot(cp_value), pos + 1, repr(label))
280
+ )
265
281
  else:
266
- raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
282
+ raise InvalidCodepoint(
283
+ "Codepoint {} at position {} of {} not allowed".format(_unot(cp_value), pos + 1, repr(label))
284
+ )
267
285
 
268
286
  check_bidi(label)
269
287
 
270
288
 
271
- def alabel(label):
272
-
289
+ def alabel(label: str) -> bytes:
273
290
  try:
274
- label = label.encode('ascii')
275
- ulabel(label)
276
- if not valid_label_length(label):
277
- raise IDNAError('Label too long')
278
- return label
291
+ label_bytes = label.encode("ascii")
292
+ ulabel(label_bytes)
293
+ if not valid_label_length(label_bytes):
294
+ raise IDNAError("Label too long")
295
+ return label_bytes
279
296
  except UnicodeEncodeError:
280
297
  pass
281
298
 
282
- if not label:
283
- raise IDNAError('No Input')
284
-
285
- label = unicode(label)
286
299
  check_label(label)
287
- label = _punycode(label)
288
- label = _alabel_prefix + label
300
+ label_bytes = _alabel_prefix + _punycode(label)
289
301
 
290
- if not valid_label_length(label):
291
- raise IDNAError('Label too long')
292
-
293
- return label
302
+ if not valid_label_length(label_bytes):
303
+ raise IDNAError("Label too long")
294
304
 
305
+ return label_bytes
295
306
 
296
- def ulabel(label):
297
307
 
308
+ def ulabel(label: Union[str, bytes, bytearray]) -> str:
298
309
  if not isinstance(label, (bytes, bytearray)):
299
310
  try:
300
- label = label.encode('ascii')
311
+ label_bytes = label.encode("ascii")
301
312
  except UnicodeEncodeError:
302
313
  check_label(label)
303
314
  return label
304
-
305
- label = label.lower()
306
- if label.startswith(_alabel_prefix):
307
- label = label[len(_alabel_prefix):]
308
- if not label:
309
- raise IDNAError('Malformed A-label, no Punycode eligible content found')
310
- if label.decode('ascii')[-1] == '-':
311
- raise IDNAError('A-label must not end with a hyphen')
312
315
  else:
313
- check_label(label)
314
- return label.decode('ascii')
316
+ label_bytes = label
317
+
318
+ label_bytes = label_bytes.lower()
319
+ if label_bytes.startswith(_alabel_prefix):
320
+ label_bytes = label_bytes[len(_alabel_prefix) :]
321
+ if not label_bytes:
322
+ raise IDNAError("Malformed A-label, no Punycode eligible content found")
323
+ if label_bytes.decode("ascii")[-1] == "-":
324
+ raise IDNAError("A-label must not end with a hyphen")
325
+ else:
326
+ check_label(label_bytes)
327
+ return label_bytes.decode("ascii")
315
328
 
316
- label = label.decode('punycode')
329
+ try:
330
+ label = label_bytes.decode("punycode")
331
+ except UnicodeError:
332
+ raise IDNAError("Invalid A-label")
317
333
  check_label(label)
318
334
  return label
319
335
 
320
336
 
321
- def uts46_remap(domain, std3_rules=True, transitional=False):
337
+ def uts46_remap(domain: str, std3_rules: bool = True, transitional: bool = False) -> str:
322
338
  """Re-map the characters in the string according to UTS46 processing."""
323
339
  from .uts46data import uts46data
324
- output = u""
325
- try:
326
- for pos, char in enumerate(domain):
327
- code_point = ord(char)
328
- uts46row = uts46data[code_point if code_point < 256 else
329
- bisect.bisect_left(uts46data, (code_point, "Z")) - 1]
340
+
341
+ output = ""
342
+
343
+ for pos, char in enumerate(domain):
344
+ code_point = ord(char)
345
+ try:
346
+ uts46row = uts46data[code_point if code_point < 256 else bisect.bisect_left(uts46data, (code_point, "Z")) - 1]
330
347
  status = uts46row[1]
331
- replacement = uts46row[2] if len(uts46row) == 3 else None
332
- if (status == "V" or
333
- (status == "D" and not transitional) or
334
- (status == "3" and not std3_rules and replacement is None)):
348
+ replacement: Optional[str] = None
349
+ if len(uts46row) == 3:
350
+ replacement = uts46row[2]
351
+ if (
352
+ status == "V"
353
+ or (status == "D" and not transitional)
354
+ or (status == "3" and not std3_rules and replacement is None)
355
+ ):
335
356
  output += char
336
- elif replacement is not None and (status == "M" or
337
- (status == "3" and not std3_rules) or
338
- (status == "D" and transitional)):
357
+ elif replacement is not None and (
358
+ status == "M" or (status == "3" and not std3_rules) or (status == "D" and transitional)
359
+ ):
339
360
  output += replacement
340
361
  elif status != "I":
341
362
  raise IndexError()
342
- return unicodedata.normalize("NFC", output)
343
- except IndexError:
344
- raise InvalidCodepoint(
345
- "Codepoint {0} not allowed at position {1} in {2}".format(
346
- _unot(code_point), pos + 1, repr(domain)))
347
-
348
-
349
- def encode(s, strict=False, uts46=False, std3_rules=False, transitional=False):
350
-
351
- if isinstance(s, (bytes, bytearray)):
352
- s = s.decode("ascii")
363
+ except IndexError:
364
+ raise InvalidCodepoint(
365
+ "Codepoint {} not allowed at position {} in {}".format(_unot(code_point), pos + 1, repr(domain))
366
+ )
367
+
368
+ return unicodedata.normalize("NFC", output)
369
+
370
+
371
+ def encode(
372
+ s: Union[str, bytes, bytearray],
373
+ strict: bool = False,
374
+ uts46: bool = False,
375
+ std3_rules: bool = False,
376
+ transitional: bool = False,
377
+ ) -> bytes:
378
+ if not isinstance(s, str):
379
+ try:
380
+ s = str(s, "ascii")
381
+ except UnicodeDecodeError:
382
+ raise IDNAError("should pass a unicode string to the function rather than a byte string.")
353
383
  if uts46:
354
384
  s = uts46_remap(s, std3_rules, transitional)
355
385
  trailing_dot = False
356
386
  result = []
357
387
  if strict:
358
- labels = s.split('.')
388
+ labels = s.split(".")
359
389
  else:
360
390
  labels = _unicode_dots_re.split(s)
361
- if not labels or labels == ['']:
362
- raise IDNAError('Empty domain')
363
- if labels[-1] == '':
391
+ if not labels or labels == [""]:
392
+ raise IDNAError("Empty domain")
393
+ if labels[-1] == "":
364
394
  del labels[-1]
365
395
  trailing_dot = True
366
396
  for label in labels:
@@ -368,19 +398,26 @@ def encode(s, strict=False, uts46=False, std3_rules=False, transitional=False):
368
398
  if s:
369
399
  result.append(s)
370
400
  else:
371
- raise IDNAError('Empty label')
401
+ raise IDNAError("Empty label")
372
402
  if trailing_dot:
373
- result.append(b'')
374
- s = b'.'.join(result)
403
+ result.append(b"")
404
+ s = b".".join(result)
375
405
  if not valid_string_length(s, trailing_dot):
376
- raise IDNAError('Domain too long')
406
+ raise IDNAError("Domain too long")
377
407
  return s
378
408
 
379
409
 
380
- def decode(s, strict=False, uts46=False, std3_rules=False):
381
-
382
- if isinstance(s, (bytes, bytearray)):
383
- s = s.decode("ascii")
410
+ def decode(
411
+ s: Union[str, bytes, bytearray],
412
+ strict: bool = False,
413
+ uts46: bool = False,
414
+ std3_rules: bool = False,
415
+ ) -> str:
416
+ try:
417
+ if not isinstance(s, str):
418
+ s = str(s, "ascii")
419
+ except UnicodeDecodeError:
420
+ raise IDNAError("Invalid ASCII in A-label")
384
421
  if uts46:
385
422
  s = uts46_remap(s, std3_rules, False)
386
423
  trailing_dot = False
@@ -388,9 +425,9 @@ def decode(s, strict=False, uts46=False, std3_rules=False):
388
425
  if not strict:
389
426
  labels = _unicode_dots_re.split(s)
390
427
  else:
391
- labels = s.split(u'.')
392
- if not labels or labels == ['']:
393
- raise IDNAError('Empty domain')
428
+ labels = s.split(".")
429
+ if not labels or labels == [""]:
430
+ raise IDNAError("Empty domain")
394
431
  if not labels[-1]:
395
432
  del labels[-1]
396
433
  trailing_dot = True
@@ -399,7 +436,7 @@ def decode(s, strict=False, uts46=False, std3_rules=False):
399
436
  if s:
400
437
  result.append(s)
401
438
  else:
402
- raise IDNAError('Empty label')
439
+ raise IDNAError("Empty label")
403
440
  if trailing_dot:
404
- result.append(u'')
405
- return u'.'.join(result)
441
+ result.append("")
442
+ return ".".join(result)