Rename *Importation structs to *Import (#5185)

## Summary

I find "Importation" a bit awkward, it may not even be grammatically
correct here.
This commit is contained in:
Charlie Marsh 2023-06-19 12:09:10 -04:00 committed by GitHub
parent e3c12764f8
commit 94abf7f088
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 61 additions and 68 deletions

View file

@ -13,8 +13,8 @@ use ruff_python_stdlib::path::is_python_stub_file;
use ruff_python_stdlib::typing::is_typing_extension;
use crate::binding::{
Binding, BindingFlags, BindingId, BindingKind, Bindings, Exceptions, FromImportation,
Importation, SubmoduleImportation,
Binding, BindingFlags, BindingId, BindingKind, Bindings, Exceptions, FromImport, Import,
SubmoduleImport,
};
use crate::context::ExecutionContext;
use crate::definition::{Definition, DefinitionId, Definitions, Member, Module};
@ -417,7 +417,7 @@ impl<'a> SemanticModel<'a> {
let head = call_path.first()?;
let binding = self.find_binding(head)?;
match &binding.kind {
BindingKind::Importation(Importation {
BindingKind::Import(Import {
qualified_name: name,
}) => {
if name.starts_with('.') {
@ -434,7 +434,7 @@ impl<'a> SemanticModel<'a> {
Some(source_path)
}
}
BindingKind::SubmoduleImportation(SubmoduleImportation {
BindingKind::SubmoduleImport(SubmoduleImport {
qualified_name: name,
}) => {
let name = name.split('.').next().unwrap_or(name);
@ -442,7 +442,7 @@ impl<'a> SemanticModel<'a> {
source_path.extend(call_path.into_iter().skip(1));
Some(source_path)
}
BindingKind::FromImportation(FromImportation {
BindingKind::FromImport(FromImport {
qualified_name: name,
}) => {
if name.starts_with('.') {
@ -493,7 +493,7 @@ impl<'a> SemanticModel<'a> {
// Ex) Given `module="sys"` and `object="exit"`:
// `import sys` -> `sys.exit`
// `import sys as sys2` -> `sys2.exit`
BindingKind::Importation(Importation { qualified_name }) => {
BindingKind::Import(Import { qualified_name }) => {
if qualified_name == &module {
if let Some(source) = binding.source {
// Verify that `sys` isn't bound in an inner scope.
@ -514,7 +514,7 @@ impl<'a> SemanticModel<'a> {
// Ex) Given `module="os.path"` and `object="join"`:
// `from os.path import join` -> `join`
// `from os.path import join as join2` -> `join2`
BindingKind::FromImportation(FromImportation { qualified_name }) => {
BindingKind::FromImport(FromImport { qualified_name }) => {
if let Some((target_module, target_member)) = qualified_name.split_once('.')
{
if target_module == module && target_member == member {
@ -537,7 +537,7 @@ impl<'a> SemanticModel<'a> {
}
// Ex) Given `module="os"` and `object="name"`:
// `import os.path ` -> `os.name`
BindingKind::SubmoduleImportation(SubmoduleImportation { .. }) => {
BindingKind::SubmoduleImport(SubmoduleImport { .. }) => {
if name == module {
if let Some(source) = binding.source {
// Verify that `os` isn't bound in an inner scope.