Delete examples

This commit is contained in:
Charlie Marsh 2023-05-06 23:52:14 -04:00
parent da8481c97d
commit b7517d4511
5 changed files with 5 additions and 84 deletions

View File

@ -1,72 +0,0 @@
use std::mem::size_of_val;
#[derive(Clone, Debug)]
pub struct Export<'a> {
/// The names of the bindings exported via `__all__`.
pub names: Vec<&'a str>,
}
#[derive(Clone, Debug)]
pub struct Importation<'a> {
/// The name to which the import is bound.
/// Given `import foo`, `name` would be "foo".
/// Given `import foo as bar`, `name` would be "bar".
pub name: &'a str,
/// The full name of the module being imported.
/// Given `import foo`, `full_name` would be "foo".
/// Given `import foo as bar`, `full_name` would be "foo".
pub full_name: &'a str,
}
#[derive(Clone, Debug)]
pub struct FromImportation<'a> {
/// The name to which the import is bound.
/// Given `from foo import bar`, `name` would be "bar".
/// Given `from foo import bar as baz`, `name` would be "baz".
pub name: &'a str,
/// The full name of the module being imported.
/// Given `from foo import bar`, `full_name` would be "foo.bar".
/// Given `from foo import bar as baz`, `full_name` would be "foo.bar".
pub full_name: String,
}
#[derive(Clone, Debug)]
pub struct SubmoduleImportation<'a> {
/// The parent module imported by the submodule import.
/// Given `import foo.bar`, `module` would be "foo".
pub name: &'a str,
/// The full name of the submodule being imported.
/// Given `import foo.bar`, `full_name` would be "foo.bar".
pub full_name: &'a str,
}
// If we box, this goes from 48 to 16
// If we use a u32 pointer, this goes to 8
#[derive(Clone, Debug)]
pub enum BindingKind {
Annotation,
Argument,
Assignment,
NamedExprAssignment,
Binding,
LoopVar,
Global,
Nonlocal,
Builtin,
ClassDefinition,
FunctionDefinition,
// 32
Export(u32),
FutureImportation,
// 40
Importation(u32),
// 48
FromImportation(u32),
// 48
SubmoduleImportation(u32),
}
fn main() {
let smart = BindingKind::Assignment;
dbg!(size_of_val(&smart));
}

View File

@ -1,8 +1,6 @@
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};
use ruff_python_semantic::binding::{ use ruff_python_semantic::binding::{Binding, BindingKind, ExecutionContext};
Binding, BindingKind, ExecutionContext, FromImportation, Importation, SubmoduleImportation,
};
/// ## What it does /// ## What it does
/// Checks for runtime imports defined in a type-checking block. /// Checks for runtime imports defined in a type-checking block.

View File

@ -2,9 +2,7 @@ use std::path::Path;
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};
use ruff_python_semantic::binding::{ use ruff_python_semantic::binding::{Binding, BindingKind, ExecutionContext};
Binding, BindingKind, ExecutionContext, FromImportation, Importation, SubmoduleImportation,
};
use crate::rules::isort::{categorize, ImportSection, ImportType}; use crate::rules::isort::{categorize, ImportSection, ImportType};
use crate::settings::Settings; use crate::settings::Settings;
@ -160,7 +158,7 @@ impl Violation for TypingOnlyStandardLibraryImport {
} }
/// Return `true` if `this` is implicitly loaded via importing `that`. /// Return `true` if `this` is implicitly loaded via importing `that`.
fn is_implicit_import(this: &Binding, that: &Binding) -> bool { fn is_implicit_import(_this: &Binding, _that: &Binding) -> bool {
true true
// match &this.kind { // match &this.kind {
// BindingKind::Importation(Importation { // BindingKind::Importation(Importation {

View File

@ -3,7 +3,7 @@ use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::Violation; use ruff_diagnostics::Violation;
use ruff_diagnostics::{Diagnostic, DiagnosticKind}; use ruff_diagnostics::{Diagnostic, DiagnosticKind};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};
use ruff_python_semantic::binding::{BindingKind, Importation}; use ruff_python_semantic::binding::BindingKind;
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::registry::Rule; use crate::registry::Rule;

View File

@ -11,10 +11,7 @@ use ruff_python_stdlib::path::is_python_stub_file;
use ruff_python_stdlib::typing::TYPING_EXTENSIONS; use ruff_python_stdlib::typing::TYPING_EXTENSIONS;
use crate::analyze::visibility::{module_visibility, Modifier, VisibleScope}; use crate::analyze::visibility::{module_visibility, Modifier, VisibleScope};
use crate::binding::{ use crate::binding::{Binding, BindingId, BindingKind, Bindings, Exceptions, ExecutionContext};
Binding, BindingId, BindingKind, Bindings, Exceptions, ExecutionContext, FromImportation,
Importation, SubmoduleImportation,
};
use crate::node::{NodeId, Nodes}; use crate::node::{NodeId, Nodes};
use crate::scope::{Scope, ScopeId, ScopeKind, Scopes}; use crate::scope::{Scope, ScopeId, ScopeKind, Scopes};